-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.production.js
44 lines (42 loc) · 1.3 KB
/
webpack.production.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
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const StyleExtHtmlWebpackPlugin = require('style-ext-html-webpack-plugin');
const common = require('./webpack.common');
const commonConfig = common({
mode: 'production',
});
module.exports = {
...commonConfig,
mode: 'production',
devtool: 'source-map',
optimization: {
minimizer: [new TerserJSPlugin(), new OptimizeCSSAssetsPlugin()],
},
plugins: [
...commonConfig.plugins,
new CleanWebpackPlugin(),
new CopyPlugin([
{
from: path.resolve(__dirname, 'public/favicon.ico'),
to: path.resolve(__dirname, 'dist'),
},
]),
new MiniCssExtractPlugin({
filename: 'static/css/[name].[hash].css',
chunkFilename: 'static/css/[id].[hash].css',
}),
new StyleExtHtmlWebpackPlugin(),
new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
generateStatsFile: true,
statsOptions: {
source: false,
},
}),
],
};