Webpack Bundle Analyzer is a crucial development tool for visualizing the contents of Webpack output bundles as an interactive, zoomable treemap. It helps developers identify what modules contribute most to bundle size, discover unintentionally included dependencies, and optimize the overall build output. The current stable version, 5.3.0, leverages modern ECMA features and continues to be actively maintained with a regular cadence of minor and patch releases. A key differentiator is its ability to parse minified bundles and display their real, gzipped, Brotli, or Zstandard sizes, providing accurate insights into production build sizes. It functions both as a Webpack plugin and a standalone CLI utility.
npm install webpack-bundle-analyzerVerified import paths — ran on the pinned version, not inferred.
This Webpack configuration demonstrates how to integrate `webpack-bundle-analyzer` as a plugin, starting an interactive server to visualize your bundle.
Upgrade your Node.js environment to version 20.9.0 or newer, or stick to `webpack-bundle-analyzer` v4.x for older Node.js versions.
If using Webpack 4, downgrade to `webpack-bundle-analyzer@4.x.x`. For Webpack 5+, use `webpack-bundle-analyzer@5.x.x`.
Configure a different `analyzerPort` in the plugin options, for example: `new BundleAnalyzerPlugin({ analyzerPort: 8889 })`.Always consult the documentation for your installed major version to ensure correct option usage, especially for `analyzerPort` and `reportFilename`.
Run `npm install --save-dev webpack-bundle-analyzer` or `yarn add -D webpack-bundle-analyzer`.
Specify a different port in the plugin options: `new BundleAnalyzerPlugin({ analyzerPort: 8889 })`.Ensure you are using named import/require: `import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';` or `const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');`.