-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
46 lines (44 loc) · 1.19 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
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i
const zopfli = require('@gfx/zopfli')
const BrotliPlugin = require('brotli-webpack-plugin')
const dynamicPluginList = [
new CompressionWebpackPlugin({
algorithm(input, compressionOptions, callback) {
return zopfli.gzip(input, compressionOptions, callback)
},
compressionOptions: {
numiterations: 15
},
minRatio: 0.99,
test: productionGzipExtensions
}),
new BrotliPlugin({
test: productionGzipExtensions,
minRatio: 0.99
})
]
module.exports = (env, argv) => {
return {
entry: './index.js',
output: {
filename: argv.mode === 'production' ? './bundle.min.js' : './bundle.js',
library: 'fpEs',
chunkFormat: 'array-push',
},
mode: argv.mode === 'production' ? 'production' : 'development',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
'babel-loader',
],
},
]
},
target: ['es5'],
plugins: dynamicPluginList,
};
};