-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.prod.js
64 lines (57 loc) · 1.19 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
62
63
64
const { merge } = require("webpack-merge"),
{ GenerateSW } = require("workbox-webpack-plugin"),
packageJson = require("./package"),
{
entry,
output,
cssRule,
fontRule,
iconRule,
providejQuery,
extractCss,
createIndexHtml,
copyStaticAssets,
config,
} = require("./webpack.common");
module.exports = merge(config, {
mode: "production",
// Use default entry
entry,
// Use default output with chunk hash in file names
output: merge(output, {
hashDigestLength: 6,
filename: "[name]-[chunkhash].js",
assetModuleFilename: "[name]-[contenthash][ext]",
}),
module: {
rules: [
cssRule,
merge(fontRule, {
generator: {
// Include hash in file names
filename: "fonts/[name]-[contenthash][ext]",
},
}),
iconRule,
],
},
// Extract full, separate source maps
devtool: "source-map",
plugins: [
providejQuery,
extractCss({ filename: "[name]-[chunkhash].css" }),
createIndexHtml,
copyStaticAssets,
new GenerateSW({
cacheId: packageJson.name,
skipWaiting: true,
clientsClaim: true,
}),
],
// Fail if any chunks exceed performance budget
performance: {
hints: "error",
maxEntrypointSize: 900000,
maxAssetSize: 600000,
},
});