-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
executable file
·60 lines (48 loc) · 1.02 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
// detect environmental settings
const avoidBabel = process.env.NO_BABEL === 'true';
const avoidMinify = process.env.NO_MINIFY === 'true';
function determineDestFileFromEnv() {
// output filename that's joined by dot-names
const fileParts = ['dist/restie'];
if (!avoidBabel) {
fileParts.push('dist');
}
if (!avoidMinify) {
fileParts.push('min');
}
// add extension
fileParts.push('js');
return fileParts.join('.');
}
function determinePluginsFromEnv() {
// define plugins dynamically
const plugins = [];
if (!avoidBabel) {
const babel = require('rollup-plugin-babel');
plugins.push(
babel({
exclude: 'node_modules/**',
// babelrc: false,
})
);
}
if (!avoidMinify) {
const { terser } = require('rollup-plugin-terser');
plugins.push(
terser({
mangle: true,
})
);
}
return plugins;
}
// configuration file
module.exports = {
input: 'src/restie.js',
output: {
file: determineDestFileFromEnv(),
format: 'cjs',
sourcemap: !avoidMinify,
},
plugins: determinePluginsFromEnv(),
}