Enable BundleAnalyzerPlugin + remove 'yarn analyze'
Use the env to opt in.
This commit is contained in:
parent
d211450b5b
commit
b508fe8679
2 changed files with 12 additions and 1 deletions
|
@ -20,7 +20,6 @@
|
|||
},
|
||||
"main": "./dist/electron/main.js",
|
||||
"scripts": {
|
||||
"analyze": "yarn compile && source-map-explorer --no-border-checks web/dist/public/*.js --html analyzeResults.html",
|
||||
"compile:electron": "node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js --config webpack.electron.config.js",
|
||||
"compile:web": "yarn copyenv && cd web && node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js --config webpack.config.js",
|
||||
"compile": "cross-env NODE_ENV=production yarn compile:electron && cross-env NODE_ENV=production yarn compile:web",
|
||||
|
|
|
@ -10,6 +10,17 @@ const { ifProduction } = getIfUtils(NODE_ENV);
|
|||
const UI_ROOT = path.resolve(__dirname, 'ui/');
|
||||
const STATIC_ROOT = path.resolve(__dirname, 'static/');
|
||||
|
||||
const optInPlugins = [];
|
||||
|
||||
if (NODE_ENV !== 'development' && process.env.BUNDLE_ANALYZER_ENABLED) {
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
optInPlugins.push(new BundleAnalyzerPlugin({
|
||||
analyzerMode: 'static',
|
||||
openAnalyzer: false,
|
||||
reportFilename: process.env.BUNDLE_ANALYZER_FILENAME || 'report.html',
|
||||
}));
|
||||
}
|
||||
|
||||
let baseConfig = {
|
||||
mode: ifProduction('production', 'development'),
|
||||
devtool: ifProduction('source-map', 'eval-cheap-module-source-map'),
|
||||
|
@ -110,6 +121,7 @@ let baseConfig = {
|
|||
silent: false, // hide any errors
|
||||
defaults: true, // load '.env.defaults' as the default values if empty.
|
||||
}),
|
||||
...optInPlugins,
|
||||
],
|
||||
};
|
||||
module.exports = baseConfig;
|
||||
|
|
Loading…
Reference in a new issue