-
Notifications
You must be signed in to change notification settings - Fork 10
/
rollup.config.js
42 lines (32 loc) · 894 Bytes
/
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
import nodeResolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import { uglify } from 'rollup-plugin-uglify';
import regenerator from 'rollup-plugin-regenerator';
const { BUILD_TYPE, NODE_ENV } = process.env;
const config = {
input: 'src/index.js',
plugins: [],
output: {
globals: {
'axios': 'axios'
}
},
external: ['axios'],
};
const babelConfig = {
plugins: ['external-helpers'],
exclude: 'node_modules/**',
};
if (BUILD_TYPE === 'cjs') {
config.output = { ...config.output, format: 'cjs' };
config.plugins.push(nodeResolve(), babel(babelConfig));
}
if (BUILD_TYPE === 'umd') {
config.output = { ...config.output, format: 'umd', name: 'SSC' };
config.plugins.push(babel(babelConfig));
}
config.plugins.push(regenerator());
if (NODE_ENV === 'production') {
config.plugins.push(uglify());
}
export default config;