-
Notifications
You must be signed in to change notification settings - Fork 727
/
webpack.prod.js
47 lines (45 loc) · 1.14 KB
/
webpack.prod.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
const { mergeWithCustomize, unique } = require("webpack-merge");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
const zlib = require("zlib");
const dev = require("./webpack.dev.js");
module.exports = mergeWithCustomize({
customizeArray: unique(
"plugins",
["MiniCssExtractPlugin"],
(plugin) => plugin.constructor && plugin.constructor.name
),
})(dev, {
mode: "production",
plugins: [
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
}),
new CompressionPlugin({
algorithm: "gzip",
filename: "[path][base].gz",
compressionOptions: {
params: {
level: 9,
},
},
minRatio: 0.9,
}),
new CompressionPlugin({
algorithm: "brotliCompress",
filename: "[path][base].br",
compressionOptions: {
params: {
[zlib.constants.BROTLI_PARAM_QUALITY]:
zlib.constants.BROTLI_MAX_QUALITY,
},
},
minRatio: 0.9,
}),
],
cache: false,
devtool: false,
output: {
filename: "[name].[contenthash].js",
},
});