forked from webix-hub/webix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
95 lines (85 loc) · 2 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
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";
import common from "rollup-plugin-commonjs";
import resolve from "rollup-plugin-node-resolve";
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:`codebase/${name}.css`,
option:{
paths:[ `${__dirname}/sources/css/skins/${skin}` ]
}
}),
license({
sourceMap: true,
banner: `@license
webix <%= pkg.productName %> v.<%= pkg.version %>
This software is allowed to use under GPL or you need to obtain Commercial License
to use it in non-GPL project. Please contact [email protected] for details`
}),
resolve({ main:true, module:false }),
common({})
];
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:/^_(?!id$).*$/ },
reserved:["log", "assert"]
},
compress: {
pure_funcs:["log", "assert"]
}
}));
}
return {
treeshake,
input: `sources/${name}.js`,
plugins,
output: {
file: `codebase/${outname}.js`,
format: "umd",
name,
sourcemap
},
watch:{
chokidar: false,
include: "sources/**/*.js"
}
};
};