A webpack plugin that ingests the compiler's stats object, transforms it, and writes a JSON file (typically 'stats.json') to the output directory. Version 1.1.3 is the current stable release, updated primarily with patch-level maintenance. Key differentiator: it is a dedicated, minimal stats-file writer without the overhead of full-featured analysis tools. It supports custom transforms (sync or Promise), selective field filtering, and works with webpack 4 and 5. Maintained by Formidable Labs.
npm install webpack-stats-pluginVerified import paths — ran on the pinned version, not inferred.
Basic webpack config that writes the full stats object to a file named 'stats.json' with formatting.
Set `fields: null` to include all stats fields, or provide an array of field names you need.
If using a function for `filename`, ensure it returns a string synchronously. For async filename generation, use the `transform` option.
If you don't see the stats file, ensure you have `emit: true` (the default) or check that the webpack output path is correct.
Ensure `emit` is `true` (default) and that `filename` is within the output path. The plugin adds the file to the compiler's assets.
Run `npm install --save-dev webpack-stats-plugin` and ensure it's in node_modules.
Use `const { StatsWriterPlugin } = require('webpack-stats-plugin');` (named export) or `import { StatsWriterPlugin } from 'webpack-stats-plugin';` in ESM.Set `fields: null` to include all stats fields, or explicitly include needed fields like `['assets', 'chunks', 'modules']`.
Access `data` directly as the transformed JSON object; do not call `.toJson()` on it. For custom stats generation, use the `stats` option described above.
No dependency data recorded yet.