Skip to content

Commit

Permalink
fix: Make bundle analyzer optional feature
Browse files Browse the repository at this point in the history
  • Loading branch information
bastilian committed May 2, 2024
1 parent d4da8f0 commit 3926646
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/config/src/bin/prod.webpack.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { fecLogger, LogType } = require('@redhat-cloud-services/frontend-components-config-utilities');
import FECConfiguration from '../lib/fec.config';
import config from '../lib/index';
import commonPlugins from './webpack.plugins';
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const fecConfig: FECConfiguration = require(process.env.FEC_CONFIG_PATH!);

type Configuration = import('webpack').Configuration;
Expand All @@ -18,9 +18,16 @@ const { config: webpackConfig, plugins } = config({
plugins.push(...commonPlugins, ...externalPlugins);

const start = (env: { analyze?: string }): Configuration => {
if (env && env.analyze === 'true') {
plugins.push(new BundleAnalyzerPlugin());
}
try {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');

if (BundleAnalyzerPlugin && env && env.analyze === 'true') {
fecLogger(LogType.warn, `Webpack Bundle Analyzer support will be is deprecated and will be removed in the next major release.`);

plugins.push(new BundleAnalyzerPlugin());
}
} catch {} // eslint-disable-line

return {
...webpackConfig,
plugins,
Expand Down

0 comments on commit 3926646

Please sign in to comment.