-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.prod.js
42 lines (40 loc) · 1.09 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
const merge = require("webpack-merge");
const ImageminPlugin = require("imagemin-webpack-plugin").default;
const imageminMozjpeg = require("imagemin-mozjpeg");
const CompressionPlugin = require("compression-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const common = require("./webpack.common");
module.exports = merge(common, {
mode: "production",
performance: {
hints: false,
},
optimization: {
minimize: true,
splitChunks: {
chunks: "all",
},
},
plugins: [
new ImageminPlugin({
test: /\.(jpe?g|png|gif|svg)$/i,
pngquant: {
// lossy png compressor, remove for default lossless
quality: "75",
},
plugins: [
imageminMozjpeg({
// lossy jpg compressor, remove for default lossless
quality: "75",
}),
],
}),
new CompressionPlugin({
test: /\.(html|css|js)(\?.*)?$/i, // only compressed html/css/js, skips compressing sourcemaps etc
}),
new CleanWebpackPlugin({
verbose: true,
cleanStaleWebpackAssets: true,
}),
],
});