forked from RabbyHub/Rabby
-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.pro.config.js
53 lines (48 loc) · 1.47 KB
/
webpack.pro.config.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
const webpack = require('webpack');
const path = require('path');
const fs = require('fs-extra');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const TerserPlugin = require('terser-webpack-plugin');
const SentryCliPlugin = require('@sentry/webpack-plugin');
const paths = require('./paths');
const PROJECT_ROOT = path.resolve(__dirname, '..');
const manifestPath = process.env.ENABLE_MV3
? paths.rootResolve('src/manifest/mv3/manifest.json')
: paths.rootResolve('src/manifest/mv2/manifest.json');
const manifest = fs.readJSONSync(manifestPath);
const sentrySourceMap = !!process.env.sourcemap || false;
const config = {
mode: 'production',
devtool: sentrySourceMap ? 'source-map' : false,
performance: {
maxEntrypointSize: 2500000,
maxAssetSize: 2500000,
},
plugins: [
// new BundleAnalyzerPlugin(),
new webpack.DefinePlugin({
'process.env.BUILD_ENV': JSON.stringify('PRO'),
}),
sentrySourceMap &&
new SentryCliPlugin({
include: './dist',
ignoreFile: '.sentrycliignore',
ignore: ['node_modules', 'webpack.config.js'],
configFile: 'sentry.properties',
release: manifest.version,
}),
].filter(Boolean),
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
pure_funcs: ['console.log', 'console.debug'],
},
},
}),
],
},
};
module.exports = config;