forked from pqina/filepond
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.scripts.js
53 lines (48 loc) · 1.06 KB
/
rollup.scripts.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
import babel from 'rollup-plugin-babel';
import license from 'rollup-plugin-license';
import { terser } from 'rollup-plugin-terser';
import prettier from 'rollup-plugin-prettier';
const banner = require('./banner');
const createBuild = (options) => {
const { format, id, name, minify = false, transpile = false } = options;
// get filename
const filename = ['dist/', name];
if (format === 'es') {
filename.push('.esm');
}
if (minify) {
filename.push('.min');
}
filename.push('.js');
// collect plugins
const plugins = [];
if (transpile) {
plugins.push(babel({
exclude: ['node_modules/**']
}));
}
if (minify) {
plugins.push(terser());
}
else {
plugins.push(prettier({
singleQuote: true,
parser: 'babel'
}));
}
plugins.push(license({banner: banner(options)}));
// return Rollup config
return {
input: 'src/js/index.js',
treeshake: false,
output: [
{
format,
name: id,
file: filename.join('')
}
],
plugins
}
};
export default (metadata, configs) => configs.map(config => createBuild({ ...metadata, ...config }));