-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.production.js
58 lines (50 loc) · 1.22 KB
/
webpack.production.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
const webpack = require("webpack");
const { version } = require("./package.json");
const config = require("./webpack.config");
const TerserPlugin = require("terser-webpack-plugin");
const zlib = require("zlib");
const CompressionPlugin = require("compression-webpack-plugin");
config.mode = "production";
config.plugins.push(
new webpack.BannerPlugin({
banner: `[file] v${version}\nhttps://github.com/Cognigy/Webchat/tree/v${version}\nhttps://github.com/Cognigy/Webchat/tree/v${version}/OSS_LICENSES.txt`,
}),
);
config.plugins.push(
new CompressionPlugin({
filename: "[path][base].gz",
algorithm: "gzip",
test: /\.(js|css|html|svg|ts|tsx)$/,
threshold: 10240,
minRatio: 0.8,
}),
);
config.plugins.push(
new CompressionPlugin({
filename: "[path][base].br",
algorithm: "brotliCompress",
test: /\.(js|css|html|svg|ts|tsx)$/,
compressionOptions: {
params: {
[zlib.constants.BROTLI_PARAM_QUALITY]: 11,
},
},
threshold: 10240,
minRatio: 0.8,
}),
);
config.plugins.push(
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
);
config.optimization = {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
}),
],
usedExports: true,
};
module.exports = config;