-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
39 lines (37 loc) · 949 Bytes
/
build.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
const buble = require('rollup-plugin-buble');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const es3 = require('rollup-plugin-es3');
const uglify = require('rollup-plugin-uglify');
const filesize = require('rollup-plugin-filesize');
const presets = {
umd: {
suffix: 'umd',
format: 'umd'
},
min: {
suffix: 'min',
format: 'umd',
plugins: [
uglify({ compress: { pure_funcs: ['Object.defineProperty'] } }),
filesize()
]
}
};
module.exports = function createConfig({ name, libName, target }) {
const config = presets[target];
return {
input: `src/${name}-browser/index.js`,
output: {
file: `dist/${name}-${config.suffix}.js`,
format: config.format,
intro: config.intro,
name: libName,
sourcemap: config.sourcemap
},
plugins: [resolve(), commonjs(), es3(), buble()].concat(
config.plugins || []
),
external: config.external || []
};
};