-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
63 lines (59 loc) · 1.49 KB
/
webpack.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
'use strict';
const CompressionPlugin = require('compression-webpack-plugin');
const PrepackPlugin = require('prepack-webpack-plugin').default;
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const kit = (name) => ([
{
name,
entry: `./src/kits/${name}.js`,
output: `dist/${name}.min.js`,
minified: true,
gzipped: true,
},
{
name,
entry: `./src/kits/${name}.js`,
output: `dist/${name}.js`,
minified: false,
gzipped: false,
},
]);
const bundles = [
...kit('standard'),
...kit('lite'),
...kit('server'),
];
module.exports = bundles.map((options) => {
const plugins = [];
if (options.minified) {
plugins.push(new PrepackPlugin({}));
plugins.push(new UglifyJSPlugin());
}
if (options.gzipped) {
plugins.push(new CompressionPlugin({
asset: '[path].gz',
test: new RegExp(`${options.output.replace('.', '\\.')}$`),
}));
}
return {
name: options.name,
entry: options.entry,
output: {
path: __dirname,
filename: options.output,
},
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['env'],
},
},
}],
},
plugins,
};
});