FileManager Webpack Plugin

raw JSON →
10.0.1 verified Sat Apr 25 auth: no javascript

Webpack plugin to copy, move, delete, archive (.zip/.tar/.tar.gz), and create directories before and after builds. Current stable version is 8.x (latest published as 10.0.1 but v7+ had alpha releases with breaking changes; v8 introduced new options). Requires Node >=22.14.0 and webpack ^5.0.0. Ships TypeScript definitions. Key differentiator: supports multiple file operations in a single plugin with glob patterns and flat copy options. Alternatives like copy-webpack-plugin only handle copying.

error Cannot find module 'filemanager-webpack-plugin'
cause Package not installed or peer dependency webpack not installed.
fix
npm install filemanager-webpack-plugin --save-dev (ensure webpack is installed)
error TypeError: FileManagerPlugin is not a constructor
cause Using wrong import method (CJS with default export).
fix
Use const FileManagerPlugin = require('filemanager-webpack-plugin').default;
error Error: Options validation: archive[0].format: 'tar.gz' is not recognized
cause Using 'tar.gz' as format, but only 'tar' and 'zip' are valid.
fix
Use format: 'tar' with options: { gzip: true } instead.
breaking Upgrading from v6 to v7: copy with glob now maintains directory structure by default. Use `options.flat: true` to flatten.
fix Add `options: { flat: true }` to your copy actions if you need flattened output.
breaking v7 removed the `cpy` dependency, which may affect copy behavior for glob patterns without `flat` option.
fix Explicitly set `options.flat` to `true` or `false` to control directory structure preservation.
gotcha onStart might fire twice in watch mode. Use WatchIgnorePlugin to ignore output directories.
fix Add `new webpack.WatchIgnorePlugin({ paths: [/copied-directory/] })` to your webpack config.
deprecated The `runTasksInSeries` option is deprecated as of v8. Tasks are now always run in series.
fix Remove `runTasksInSeries` from options.
npm install filemanager-webpack-plugin
yarn add filemanager-webpack-plugin
pnpm add filemanager-webpack-plugin

Sets up the plugin to copy assets folder to dist and create a zip archive after build.

const path = require('path');
const FileManagerPlugin = require('filemanager-webpack-plugin').default;

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js',
  },
  plugins: [
    new FileManagerPlugin({
      events: {
        onEnd: {
          copy: [
            { source: './src/assets', destination: './dist/assets' },
          ],
          archive: [
            { source: './dist', destination: './release.zip' },
          ],
        },
      },
    }),
  ],
};