implements env-based bundle analyzer

This commit is contained in:
James
2020-10-07 15:55:16 -04:00
parent 319148ca68
commit 870e39961c

View File

@@ -1,5 +1,5 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const path = require('path');
const webpack = require('webpack');
const getStyleLoaders = require('./getStyleLoaders');
@@ -81,7 +81,6 @@ module.exports = (config) => {
},
},
plugins: [
// new BundleAnalyzerPlugin(),
new HtmlWebpackPlugin({
template: config.admin && config.admin.indexHTML
? path.join(config.paths.configDir, config.admin.indexHTML)
@@ -102,6 +101,10 @@ module.exports = (config) => {
});
}
if (process.env.PAYLOAD_ANALYZE_BUNDLE) {
webpackConfig.plugins.push(new BundleAnalyzerPlugin());
}
if (config.paths.scss) {
webpackConfig.resolve.alias['payload-scss-overrides'] = path.join(config.paths.configDir, config.paths.scss);
} else {