Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamzahamidi/45fa8309dca9156e41312a9fdd311131 to your computer and use it in GitHub Desktop.
Save hamzahamidi/45fa8309dca9156e41312a9fdd311131 to your computer and use it in GitHub Desktop.
// script to enable webpack-bundle-analyzer
process.env.NODE_ENV = 'production';
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
const webpackConfigProd = require('react-scripts/config/webpack.config')('production');
webpackConfigProd.plugins.push(new BundleAnalyzerPlugin());
// actually running compilation and waiting for plugin to start explorer
webpack(webpackConfigProd, (err, stats) => {
if (err || stats.hasErrors()) {
console.error(err);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment