-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathwebpack.config.prod.client.js
56 lines (50 loc) · 1.5 KB
/
webpack.config.prod.client.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
const merge = require('webpack-merge');
const baseConfig = require('./webpack.config.js');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const BrotliPlugin = require('brotli-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
let pathsToClean = ['dist/', 'build/', 'public/'];
let cleanOptions = {
root: path.resolve(__dirname, '../'),
exclude: ['template.html', 'manifest.json', 'favicon.ico'],
verbose: true,
dry: false
};
const config = {
name: 'client',
target: 'web',
mode: 'production',
entry: {
main: './src/index.js',
other: './src/other.js'
},
output: {
path: path.resolve(__dirname, '../public'),
// publicPath: '/',
filename: './[name]-bundle.js'
},
optimization: {
minimizer: [new UglifyJsPlugin()]
},
plugins: [
new CleanWebpackPlugin(pathsToClean, cleanOptions),
new MiniCssExtractPlugin({
filename: '[name]-[contenthash].css'
}),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/g,
cssProcessor: require('cssnano'),
cssProcessorOptions: { discardComments: { removeAll: true } },
canPrint: true
}),
new CompressionPlugin({
algorithm: 'gzip'
}),
new BrotliPlugin()
]
};
module.exports = merge(baseConfig, config);