webpack-asset-file-plugin

raw JSON →
1.0.2 verified Fri May 01 auth: no javascript maintenance

A webpack plugin (v1.0.2) that generates asset files (e.g., JSON) containing the mapping of webpack output assets with their sizes and hash values. It is designed for webpack 4 and helps track compiled assets. The plugin writes an asset.json file to the output directory with details like filename, size, and hash. It is a niche tool compared to plugins like assets-webpack-plugin or webpack-manifest-plugin, which are more feature-rich and actively maintained. Release cadence is low (latest 2018), with no recent updates.

error TypeError: Cannot read property 'compilation' of undefined
cause Plugin applied incorrectly, or not added to plugins array.
fix
Ensure plugin is instantiated and added to webpack's plugins array in config.
error Error: [webpack-asset-file-plugin] options.filename is required
cause Missing `filename` option when instantiating plugin.
fix
Add filename option, e.g., new AssetFilePlugin({ filename: 'assets.json' }).
breaking Plugin is designed for webpack 4 only; may not work with webpack 5 due to removed hooks.
fix Use an alternative like webpack-manifest-plugin for webpack 5.
deprecated The package has not been updated since 2018; consider it in maintenance mode.
fix Switch to actively maintained plugins like assets-webpack-plugin or webpack-manifest-plugin.
gotcha The `update` option set to false will overwrite the asset file on each build instead of merging.
fix Set `update: true` to merge with existing asset file, if that behavior is desired.
npm install webpack-asset-file-plugin
yarn add webpack-asset-file-plugin
pnpm add webpack-asset-file-plugin

Shows how to configure the plugin to output asset.json with compiled file details, excluding source maps.

const AssetFilePlugin = require('webpack-asset-file-plugin');

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js',
  },
  plugins: [
    new AssetFilePlugin({
      filename: 'asset.json',
      excludeAssets: [/.*\.map$/],
      update: false,
      path: path.resolve(__dirname, 'dist'),
    }),
  ],
};