-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathwebpack.prod.mjs
More file actions
49 lines (46 loc) · 1.27 KB
/
webpack.prod.mjs
File metadata and controls
49 lines (46 loc) · 1.27 KB
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
// Import External Dependencies
import path from "node:path";
import { fileURLToPath } from "node:url";
import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
import { merge } from "webpack-merge";
import { InjectManifest } from "workbox-webpack-plugin";
// Load Common Configuration
import ProdAssetsManifest from "./src/ProdAssetsManifest.mjs";
import common from "./webpack.common.mjs";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export default (env) =>
merge(common(env), {
mode: "production",
entry: {
index: {
import: "./index.jsx",
filename: "index.[contenthash].js",
},
},
output: {
filename: "[name].[contenthash].js",
},
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
test: /node_modules/,
chunks: "initial",
enforce: true,
filename: "vendor.[contenthash].js",
},
},
},
minimizer: ["...", new CssMinimizerPlugin()],
},
plugins: [
new InjectManifest({
swSrc: path.join(__dirname, "src/sw.js"),
swDest: "sw.js",
// exclude license
exclude: [/license\.txt/i],
}),
new ProdAssetsManifest(),
],
});