-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.js
51 lines (49 loc) · 1.39 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
48
49
50
51
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require('terser-webpack-plugin');
module.exports = merge(common, {
mode: 'production',
module: {
rules: [
{
test: /\.(gif|png|jpe?g|svg)$/i,
include: [
path.resolve(__dirname, "src/img/opt")
],
use: [
{loader: 'file-loader', options:{name: '[name].[ext]',outputPath: 'img', } },
{
loader: 'image-webpack-loader',
options: {
mozjpeg: {
progressive: true,
quality: 75
},
// optipng.enabled: false will disable optipng
optipng: {
enabled: true,
}
}
}
]
}
]
},
optimization: {
minimizer: [new TerserPlugin({ cache: true, parallel: true, terserOptions: { output: {comments: false} } }),
new CssMinimizerPlugin(),]
}
/*plugins: [
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/g,
cssProcessor: require('cssnano'),
cssProcessorPluginOptions: {
preset: ['default', { discardComments: { removeAll: true } }],
},
canPrint: true
})
]*/
});