-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.js
46 lines (45 loc) · 1.5 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
const path = require('path')
const webpack = require('webpack')
const merge = require('webpack-merge')
const common = require('./webpack.common.js')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = merge(common, {
mode: 'production',
plugins: [
new webpack.HotModuleReplacementPlugin(),
new CleanWebpackPlugin({
cleanAfterEveryBuildPatterns: ['dist']
}),
new MiniCssExtractPlugin({
filename: 'style.[contenthash].css'
}),
new HtmlWebpackPlugin({
template: path.join(process.cwd(), 'src/index.html'),
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
minifyJS: true,
minifyCSS: true
},
inject: true
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
})
],
output: {
filename: '[name].[hash].js',
chunkFilename: '[name].[hash].chunk.js'
},
performance: {
assetFilter: (assetFilename) => !(/(\.map$)|(^(main\.|favicon\.))/.test(assetFilename))
}
})