-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
34 lines (33 loc) · 1023 Bytes
/
webpack.config.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
const { merge } = require("webpack-merge");
const webpack = require("webpack");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const TerserPlugin = require("terser-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const baseConfig = require("./webpack.config.base");
module.exports = merge(baseConfig, {
mode: "production",
optimization: {
minimizer: [new TerserPlugin({}), new OptimizeCSSAssetsPlugin({})],
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name]-[hash].css",
chunkFilename: "[id]-[hash].css",
}),
new BundleAnalyzerPlugin({
analyzerMode: "static",
openAnalyzer: false,
}),
new webpack.DefinePlugin({
"process.env": {
API_URL: JSON.stringify(process.env.API_URL),
},
}),
],
externals: {
// not include react in the bundle
react: "React",
"react-dom": "ReactDOM",
},
});