-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
61 lines (60 loc) · 1.71 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
52
53
54
55
56
57
58
59
60
61
const { merge } = require("webpack-merge");
const path = require("path");
const commonConfig = require("./webpack.common");
const webpack = require("webpack");
require("dotenv").config({ path: "./.env.production" });
// const InterpolateHtmlPlugin = require("interpolate-html-plugin");
// const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
// const CopyWebpackPlugin = require("copy-webpack-plugin");
const prodConfig = {
mode: "production",
output: {
path: path.join(__dirname, "dist"),
chunkFilename: `[id].js`,
filename: `index.js`,
assetModuleFilename: "static/assets/[name][ext][query]",
clean: true,
},
plugins: [
new webpack.DefinePlugin({
"process.env": JSON.stringify(process.env),
}),
// new InterpolateHtmlPlugin({
// PUBLIC_URL: process.env.PUBLIC_URL,
// }),
// new CopyWebpackPlugin({
// patterns: [
// {
// from: "public",
// force: true,
// filter: async (resourcePath) => {
// if (resourcePath.includes("index.html")) {
// return false;
// }
// return true;
// },
// },
// ],
// }),
],
optimization: {
minimize: true,
minimizer: [
// new TerserPlugin({
// parallel: true,
// terserOptions: { format: { comments: false }, compress: true },
// }),
// new CssMinimizerPlugin({
// minify: [
// CssMinimizerPlugin.cssnanoMinify,
// CssMinimizerPlugin.cleanCssMinify,
// ],
// parallel: true,
// }),
],
},
};
module.exports = (env) => {
return merge(commonConfig(env), prodConfig);
};