-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
96 lines (86 loc) · 2.12 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import less from 'rollup-plugin-less';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import license from 'rollup-plugin-license';
import { uglify } from 'rollup-plugin-uglify';
import { eslint } from 'rollup-plugin-eslint';
module.exports = function(cli){
const pkg = require('./package.json');
const name = pkg.productTag;
const mode = cli['config-mode'] || 'fast';
const outname = cli['config-name'] || ( mode === 'min' ? `${name}.min` : name );
const skin = cli['config-skin'] || 'material';
const plugins = [
replace({
DEBUG: mode !== 'min',
VERSION: pkg.version
}),
less({
output: `dist/${name}.css`,
option: {
paths:[ `${__dirname}/sources/css/skins/${skin}` ]
}
}),
license({
sourceMap: true,
thirdParty: {
allow(dependency) {
return dependency.license === 'MIT';
},
},
banner: `@license
<%= pkg.productName %> v.<%= pkg.version %>
Copyright (c) <%= pkg.author.name %>. All rights reserved.
This work is licensed under the terms of the MIT license.
For a copy, see <https://opensource.org/licenses/MIT>.`
})
];
let sourcemap = false;
let treeshake = false;
if (mode !== 'fastest'){
plugins.push(eslint({}));
plugins.push(babel({
exclude: 'node_modules/**',
presets: [
[
'@babel/preset-env',
{
loose: true,
targets: { 'ie': '8' },
exclude: [ 'transform-function-name' ]
}
]
]
}));
if (mode !== 'fast'){
sourcemap = (mode === 'normal' || mode === 'min');
treeshake = true;
}
}
if (mode === 'min') {
plugins.push(uglify({
mangle:{
properties:{ regex:/^_/ },
reserved:['log', 'assert']
},
compress: {
pure_funcs:['log', 'assert']
}
}));
}
return {
treeshake,
input: `sources/${name}.js`,
plugins,
output: {
file: `dist/${outname}.js`,
format: 'umd',
name,
sourcemap
},
watch: {
chokidar: false,
include: 'sources/**/*.js'
}
};
};