webpack-disk-plugin

raw JSON →
0.0.2 verified Sat Apr 25 auth: no javascript abandoned

A Webpack plugin (v0.0.2) that writes specified compiler assets to disk, useful with webpack-dev-server where files are memory-only. It hooks into the after-emit event and supports regex or string asset matching, custom filenames (string or function), and nested output paths. Not updated since 2016; likely unmaintained.

error TypeError: DiskPlugin is not a constructor
cause Incorrect import for CommonJS.
fix
Use const DiskPlugin = require('webpack-disk-plugin'); without destructuring.
error Module not found: Error: Can't resolve 'webpack-disk-plugin'
cause Package not installed.
fix
Run npm install webpack-disk-plugin --save-dev
deprecated No updates since 2016; likely incompatible with Webpack 4+ and 5.
fix Consider alternative plugins like copy-webpack-plugin or webpack-manifest-plugin.
gotcha Only CommonJS require works; no ESM import.
fix Use const DiskPlugin = require('webpack-disk-plugin');
gotcha Cannot have multiple files with the same output path; only one unique output path allowed.
fix Ensure each file in the `files` array has a distinct output filename.
npm install webpack-disk-plugin
yarn add webpack-disk-plugin
pnpm add webpack-disk-plugin

Copies a stats.json and a hashed main.js file to the build directory using webpack-disk-plugin.

const DiskPlugin = require('webpack-disk-plugin');

module.exports = {
  plugins: [
    new DiskPlugin({
      output: { path: 'build' },
      files: [
        { asset: 'stats.json' },
        { asset: /[a-f0-9]{20}\.main\.js/, output: { filename: 'file.js' } }
      ]
    })
  ]
};