forked from scottohara/loot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
79 lines (69 loc) · 1.64 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const webpack = require("webpack"),
merge = require("webpack-merge"),
MinifyPlugin = require("babel-minify-webpack-plugin"),
{
entry,
output,
lessRule,
cssRule,
fontRule,
iconRule,
defineEnvironment,
cleanBuildDirectory,
providejQuery,
separateBundles,
extractAppCss,
extractVendorCss,
createIndexHtml,
copyStaticAssets,
generateServiceWorker,
config
} = require("./webpack.common"),
appCss = extractAppCss(true),
vendorCss = extractVendorCss(true);
module.exports = merge(config, {
// Use default entry
entry,
// Use default output with chunk hash in file names
output: merge(output, {
filename: "[name]-[chunkhash:6].js"
}),
module: {
rules: [
lessRule(appCss, {minimize: true}),
cssRule(vendorCss),
fontRule,
iconRule
]
},
// Extract full, separate source maps
devtool: "source-map",
plugins: [
/*
* Ensure that bundles only change when necessary by using a hash of the content for the module id
* instead of a numbers derived from the order of dependencies in the graph
*/
new webpack.HashedModuleIdsPlugin(),
defineEnvironment("production"),
providejQuery,
cleanBuildDirectory,
separateBundles,
vendorCss,
appCss,
// Minify bundles
new MinifyPlugin(),
createIndexHtml,
copyStaticAssets,
generateServiceWorker()
],
// Fail if any chunks exceed performance budget
performance: {
hints: "error",
/*
* Needed temporarily because BabelMinifyWebpackPlugin doesn't support dead-code elimination
* (remove after switching to UglifyJSWebpackPlugin)
*/
maxEntrypointSize: 1000000,
maxAssetSize: 630000
}
});