-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrollup.config.js
56 lines (49 loc) · 1.26 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
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
import sourcemaps from 'rollup-plugin-sourcemaps';
import resolve from 'rollup-plugin-node-resolve';
const packages = require('./package.json');
const paths = {
root: '/',
source: {
root: process.env.NODE_ENV === 'example' ? './example/' : './src/',
},
dist: {
root: process.env.NODE_ENV === 'example' ? './example/dist/' : './dist/',
},
};
let fileName,
Configure;
switch (process.env.NODE_ENV) {
case 'development':
fileName = packages.name.replace('@meitu/', '');
break;
case 'example':
fileName = `example`;
break;
case 'production':
fileName = `${packages.name.replace('@meitu/', '')}.min`;
break;
}
Configure = {
entry: `${paths.source.root}index.js`,
moduleName: packages.moduleName,
// moduleId: packages.moduleName,
sourceMap: true,
targets: [{
dest: `${paths.dist.root}${fileName}.js`,
format: 'umd',
}],
globals: {
// is: '@meitu/is',
},
plugins: [
babel(),
sourcemaps(),
resolve(),
],
};
if (process.env.NODE_ENV === 'production') {
Configure.plugins.push(uglify());
}
export default Configure;