The `stats-webpack-plugin` is a Webpack plugin designed to write the build statistics to a file, typically `stats.json`. This enables developers and tools to analyze various aspects of the build, such as module sizes, dependencies, and timing information, by exposing Webpack's internal `stats.toJson` output. The package's current stable version is 0.7.0, last published in 2018, making it effectively abandoned and primarily compatible with older Webpack versions (likely Webpack 1.x, as its peer dependency states `>=1.0.0`). It differentiates itself by offering a straightforward, no-frills method to obtain raw build statistics for custom processing, unlike more feature-rich alternatives that provide integrated analysis and visualization tools. Its lack of recent updates means it does not support modern Webpack features or syntax.
npm install stats-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `stats-webpack-plugin` into a basic Webpack configuration to generate a `stats.json` file in the output directory, applying basic filtering.
For modern Webpack versions, use Webpack's native `stats` configuration option (e.g., `stats: 'minimal'` or `stats: { preset: 'minimal', ... }`) directly in `webpack.config.js` or consider more actively maintained plugins like `webpack-bundle-analyzer`.Always use `const StatsPlugin = require('stats-webpack-plugin');` to import the plugin.If attempting to use this plugin with a newer Webpack version, consult the Webpack documentation for the `stats` option corresponding to your Webpack version. However, it's strongly recommended to use native Webpack features or alternative tools for modern setups.
Change your import statement to `const StatsPlugin = require('stats-webpack-plugin');`.Verify that `stats-webpack-plugin` is correctly installed in your `node_modules` directory and that your Node.js environment is compatible with CommonJS modules.
This plugin is not compatible with Webpack 4 or 5+. Migrate to using Webpack's native `stats` configuration directly in your `webpack.config.js` or use a modern bundle analysis tool.