forked from leather-io/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
71 lines (62 loc) · 2.1 KB
/
webpack.config.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
/* eslint-disable @typescript-eslint/no-var-requires */
const config = require('./webpack.config.base');
const packageJson = require('../package.json');
const { EsbuildPlugin } = require('esbuild-loader');
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
const webpack = require('webpack');
const shouldMinify = JSON.parse(process.env.MINIFY_PRODUCTION_BUILD || false);
const sentryAuthToken = process.env.SENTRY_AUTH_TOKEN;
config.mode = 'production';
// Basically, disable any code splitting stuff
config.optimization = {
...config.optimization,
minimize: shouldMinify,
moduleIds: 'deterministic',
splitChunks: {
chunks(chunk) {
// Only enable code splitting on main bundle
return chunk.name === 'index';
},
hidePathInfo: false,
minSize: 10000,
maxAsyncRequests: Infinity,
maxInitialRequests: Infinity,
},
...(shouldMinify
? {
minimizer: [
new EsbuildPlugin({
target: 'esnext',
}),
],
}
: {}),
};
config.plugins = [
...config.plugins,
new webpack.SourceMapDevToolPlugin({
// These entry points are excuted in an app's context. If we generate source
// maps for them, the browser attempts to load them from the inaccessible
// `chrome-extension://` protocol, throwing console errors. To prevent
// these, we do not generate source maps for these files. Otherwise, these
// `SourceMapDevToolPlugin` options emulate the `devtool: source-map` config
exclude: [/inpage/, /content\-script/, /browser\-polyfill/],
filename: '[file].map',
}),
...(sentryAuthToken
? [
new SentryWebpackPlugin({
org: 'trust-machines',
project: 'hiro-wallet',
// Specify the directory containing build artifacts
include: './dist',
// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and needs the `project:releases` and `org:read` scopes
authToken: sentryAuthToken,
release: packageJson.version,
}),
]
: []),
];
config.devtool = false;
module.exports = config;