-
Notifications
You must be signed in to change notification settings - Fork 17
/
rollup.js
40 lines (34 loc) · 1.32 KB
/
rollup.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
const {rollup} = require('rollup');
const {default: babel} = require('@rollup/plugin-babel');
const clear = require('rollup-plugin-clear');
const {terser} = require('rollup-plugin-terser');
const run = (entry, minimize) => {
const options = {
context: __dirname,
input: entry,
plugins: [
clear(['map', 'index.js', 'fp.js', '*.min.js', '*.es.js']),
babel({babelHelpers: 'bundled'}),
],
};
if (minimize) {
options.plugins.push(terser());
}
return rollup(options);
};
const main = async () => {
const bundlings = [
run('src/index.js', false),
run('src/index.js', true),
run('src/fp.js', false),
run('src/fp.js', true),
];
const [index, indexMinimized, fp, fpMinimized] = await Promise.all(bundlings);
index.write({format: 'umd', name: 'sanUpdate', file: 'index.js', sourcemap: true});
index.write({format: 'module', file: 'index.es.js', sourcemap: true});
fp.write({format: 'umd', name: 'sanUpdate', file: 'fp.js', sourcemap: true});
fp.write({format: 'module', file: 'fp.es.js', sourcemap: true});
indexMinimized.write({format: 'umd', name: 'sanUpdate', file: 'index.min.js', sourcemap: true});
fpMinimized.write({format: 'umd', name: 'sanUpdate', file: 'fp.min.js', sourcemap: true});
};
main();