-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrollup.config.js
43 lines (41 loc) · 1.21 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
import pkg from './package.json' assert { type: 'json' };
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import terser from '@rollup/plugin-terser';
import { visualizer } from 'rollup-plugin-visualizer';
function bundle(format, filename, options = {}) {
return {
input: 'src/index.js',
output: {
file: filename,
format: format,
name: 'MapboxDrawGeodesic',
sourcemap: true,
globals: {
'@mapbox/mapbox-gl-draw': 'MapboxDraw',
},
},
external: [
...Object.keys(pkg.peerDependencies),
...(!options.resolve ? [
...Object.keys(pkg.dependencies),
] : []),
],
plugins: [
...(options.resolve ? [resolve()] : []),
commonjs(),
babel({ babelHelpers: 'runtime' }),
options.minimize ? terser() : false,
options.stats ? visualizer({
filename: filename + '.stats.html',
}) : false,
],
};
}
export default [
bundle('cjs', pkg.main),
bundle('es', pkg.module),
bundle('umd', pkg.browser.replace('.min', ''), { resolve: true, stats: true }),
bundle('umd', pkg.browser, { resolve: true, minimize: true }),
];