forked from maptalks/maptalks.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
84 lines (79 loc) · 2.18 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const commonjs = require('rollup-plugin-commonjs'),
resolve = require('rollup-plugin-node-resolve'),
babel = require('rollup-plugin-babel'),
json = require('rollup-plugin-json');
const pkg = require('./package.json');
const testing = process.env.BUILD === 'test';
const dev = process.env.BUILD === 'dev';
console.log(process.env.BUILD);
const isDebug = testing || dev;
const plugins = testing ?
[
['istanbul', {
// TileLayerGLRenderer is not testable on CI
exclude: ['test/**/*.js', 'src/core/mapbox/*.js', 'src/util/dom.js', 'src/renderer/layer/tilelayer/TileLayerGLRenderer.js', 'src/renderer/layer/ImageGLRenderable.js', 'node_modules/**/*']
}]]
:
[];
const year = new Date().getFullYear();
const banner = `/*!\n * ${pkg.name} v${pkg.version}\n * LICENSE : ${pkg.license}\n * (c) 2016-${year} maptalks.org\n */`;
const outro = `typeof console !== 'undefined' && console.log && console.log('${pkg.name} v${pkg.version}');`;
const rollupPlugins = [
json(),
resolve({
module: true,
jsnext: true,
main: true
}),
commonjs(),
babel({
plugins
})
];
const external = ['rbush', 'frustum-intersects', 'simplify-js', 'zousan'];
const builds = [
{
input: 'src/index.js',
plugins: rollupPlugins,
output: [
{
'sourcemap': isDebug,
'format': 'umd',
'name': 'maptalks',
banner,
outro,
'file': pkg.main
}
]
},
{
input: 'src/index.js',
plugins: rollupPlugins,
external,
output: [
{
'sourcemap': false,
'format': 'es',
banner,
'file': pkg.module
}
]
},
//for browser esm
{
input: 'src/index.js',
plugins: rollupPlugins,
output: [
{
'sourcemap': false,
'format': 'es',
banner,
'file': pkg.module_browser
}
]
}];
if (isDebug) {
module.exports = [builds[0]];
} else {
module.exports = builds;
}