The `dumpmeta-webpack-plugin` is a Webpack plugin designed to save build-time metadata to a specified file, typically for post-build analysis or integration with other tools. As of its current stable version, 0.2.0, it offers compatibility with Webpack 5. The plugin differentiates itself through its simplicity and a `prepare` option that allows developers to precisely extract and format the desired properties from Webpack's `stats` object before serialization, ensuring only relevant, JSON-serializable data is saved. While release cadence appears infrequent, updates address major Webpack version compatibility. It serves as a focused utility for build introspection rather than a comprehensive reporting tool.
npm install dumpmeta-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to configure and use `DumpMetaPlugin` in a `webpack.config.js` to save custom build metadata, including build hash and timestamps, to a `meta.json` file.
Review and update your `prepare` function logic when migrating to Webpack 5 to ensure it correctly extracts properties from the potentially changed `stats` object structure. Refer to Webpack 5's `stats` documentation.
Ensure that the object returned by your `prepare` function contains only primitive values, arrays, and plain objects. Transform complex types (e.g., Dates) into serializable formats like ISO strings.
Install using `npm install dumpmeta-webpack-plugin --save-dev` or `yarn add dumpmeta-webpack-plugin --dev`.
For ES Modules, use `import { DumpMetaPlugin } from 'dumpmeta-webpack-plugin';`. For CommonJS, use `const { DumpMetaPlugin } = require('dumpmeta-webpack-plugin');`.Carefully inspect the object returned by your `prepare` function. Ensure it does not include any properties that recursively refer back to themselves or parent objects. Only extract specific, necessary primitive properties.
Ensure that the directory where `meta.json` is to be written has appropriate write permissions for the user running the Webpack build. Alternatively, specify a different output `filename` to a writable location.