forked from maptalks/maptalks.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
114 lines (106 loc) · 2.89 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const commonjs = require('@rollup/plugin-commonjs'),
resolve = require('@rollup/plugin-node-resolve'),
babel = require('@rollup/plugin-babel'),
json = require('@rollup/plugin-json'),
typescript = require('@rollup/plugin-typescript'),
terser = require('@rollup/plugin-terser');
const pkg = require('./package.json');
const { dts } = require("rollup-plugin-dts");
const testing = process.env.BUILD === 'test';
const dev = process.env.BUILD === 'dev';
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(),
typescript()
];
// const compilePlugins = [
// babel({
// plugins,
// babelHelpers: 'bundled'
// })
// ];
// if (!isDebug) {
// rollupPlugins.push(terser(), ...compilePlugins)
// } else {
// rollupPlugins.push(...compilePlugins);
// }
// const external = ['rbush', 'frustum-intersects', 'simplify-js'];
const builds = [
{
input: 'src/index.ts',
plugins: rollupPlugins,
output: [
{
'sourcemap': true,
'format': 'umd',
'name': 'maptalks',
banner,
outro,
'file': pkg.main
}
]
},
{
input: 'dist/index.d.ts',
plugins: [dts()],
output: [
{
'sourcemap': true,
'format': 'es',
'name': 'maptalks',
banner,
'file': pkg['d.ts']
}
]
},
{
input: 'src/index.ts',
plugins: rollupPlugins.concat([terser()]),
output: [
{
'sourcemap': false,
'format': 'umd',
'name': 'maptalks',
banner,
outro,
'file': pkg.minify
}
]
},
//for browser esm
{
input: 'src/index.ts',
plugins: rollupPlugins,
output: [
{
'sourcemap': true,
'format': 'es',
banner,
'file': pkg.module_browser
}
]
}
];
if (isDebug) {
module.exports = builds.slice(0, 2);
} else {
module.exports = builds;
}