-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.production.js
76 lines (73 loc) · 2.02 KB
/
webpack.production.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
const pkg = require("./package.json");
const { merge } = require("webpack-merge");
const manifest = require("./src/manifest.json");
const commonWebpackConfiguration = require("./webpack.common");
const ZipPlugin = require("zip-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const WebpackExtensionManifestPlugin = require("webpack-extension-manifest-plugin");
const svgToMiniDataURI = require('mini-svg-data-uri');
module.exports = merge(commonWebpackConfiguration, {
mode: "production",
performance: {
// warn if we go even further beyond...
//since we develop a extension we don't need to care so much for size because we already have it on the disk.
maxEntrypointSize: 2000000,
maxAssetSize: 2000000,
},
module: {
rules: [
{
test: /\.svg$/,
type: "asset/inline",
generator: {
dataUrl: content => {
content = content.toString();
return svgToMiniDataURI(content);
}
}
},
]
},
plugins: [
new WebpackExtensionManifestPlugin({
config: {
base: manifest,
extend: {
version: pkg.version,
homepage_url: pkg.homepage,
},
},
}),
new ZipPlugin({
path: "zip",
filename: `${pkg.name}-v${pkg.version}`,
}),
],
optimization: {
// Without this, function names will be garbled and enableFeature won't work
concatenateModules: true,
// Automatically enabled on production; keeps it somewhat readable for AMO reviewers
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
mangle: false,
compress: {
defaults: false,
dead_code: true,
unused: true,
arguments: true,
join_vars: false,
booleans: false,
expression: false,
sequences: false,
},
output: {
beautify: true,
indent_level: 2,
},
},
}),
],
},
});