-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.prod.js
45 lines (44 loc) · 1.18 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
const { merge } = require('webpack-merge');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const ImageminPlugin = require('imagemin-webpack-plugin').default;
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'production',
devtool: 'source-map',
optimization: {
minimizer: [
new TerserPlugin({
cache: true,
exclude: /config.js/,
parallel: true
}),
new OptimizeCSSAssetsPlugin({
assetNameRegExp: /\.css$/g,
cssProcessor: require('cssnano'),
cssProcessorPluginOptions: {
preset: ['default']
},
canPrint: true
})
]
},
plugins: [
new ImageminPlugin({
maxFileSize: 10000, // Only apply this one to files equal to or under 10kb
test: /\.(png|jpg|jpeg|gif|svg)$/,
pngquant: {
quality: '95-100'
},
jpegtran: {
progressive: false
},
gifsicle: {
interlaced: false,
optimizationLevel: 1
}
}),
new CleanWebpackPlugin()
]
});