-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
rollup.config.js
61 lines (59 loc) · 1.62 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
import pkg from './package.json' assert { type: 'json' };
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import postcss from 'rollup-plugin-postcss';
import { visualizer } from 'rollup-plugin-visualizer';
import terser from '@rollup/plugin-terser';
import autoprefixer from 'autoprefixer';
import assets from 'postcss-assets';
import dts from 'rollup-plugin-dts';
import tsc from 'typescript';
function bundle(format, filename, options = {}) {
return {
input: 'src/index.ts',
output: {
file: filename,
format: format,
name: 'LeafletLasso',
sourcemap: true,
globals: {
leaflet: 'L',
},
},
external: [
...Object.keys(pkg.peerDependencies),
...(!options.resolve ? Object.keys(pkg.dependencies) : []),
],
plugins: [
...(options.resolve ? [resolve()] : []),
commonjs(),
typescript({
typescript: tsc,
clean: options.stats,
}),
postcss({ plugins: [autoprefixer(), assets()] }),
...(options.minimize ? [terser()] : []),
...(options.stats ? [visualizer({
filename: filename + '.stats.html',
})] : []),
],
};
}
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 }),
{
input: 'src/index.ts',
output: {
file: pkg.types,
format: 'es',
},
plugins: [
dts(),
postcss({ inject: false }),
],
},
];