filemanager-plugin
raw JSON → 2.9.0 verified Mon Apr 27 auth: no javascript
A file management plugin for webpack, rollup, and Vite that supports delete, copy, move, rename, zip/unzip operations before and after builds. Current stable version is 2.9.0. It provides two event-driven APIs: a simple 'events' pattern for common build lifecycle hooks (start/end) and a more flexible 'customHooks' pattern that allows binding to arbitrary compiler hooks (e.g., webpack's compile, rollup's generateBundle). Supports .zip, .tar, .tar.gz archives. Unlike similar plugins (e.g., copy-webpack-plugin, webpack-archive-plugin), filemanager-plugin bundles multiple file operations in one plugin, includes rollup and Vite support. Release cadence is irregular; last update was in 2023. Requires Node >= 14, webpack >= 4.
Common errors
error TypeError: WebpackFilemanager is not a constructor ↓
cause Using default import instead of named import.
fix
Use const { WebpackFilemanager } = require('filemanager-plugin');
error Error: Cannot find module 'filemanager-plugin' ↓
cause Package not installed or path incorrect.
fix
Run npm install filemanager-plugin --save-dev and ensure it is in node_modules.
error WebpackFilemanager is not defined ↓
cause Forgetting to destructure the named export.
fix
const { WebpackFilemanager } = require('filemanager-plugin');
Warnings
gotcha When customHooks is set, events are ignored entirely. ↓
fix Use only one of events or customHooks per plugin instance.
deprecated The 'type' field in zip items may be deprecated; some users report unzip operations failing without explicit type. ↓
fix Always specify type: 'zip' or 'tar' explicitly.
gotcha File paths are relative to the project root, not the config file location. ↓
fix Use absolute paths or paths relative to process.cwd().
gotcha The package uses CommonJS and does not provide ESM exports; cannot be imported with import syntax in default bundler setups. ↓
fix Use require() or enable interop in bundler (e.g., allowSyntheticDefaultImports).
Install
npm install filemanager-plugin yarn add filemanager-plugin pnpm add filemanager-plugin Imports
- FileManagerPlugin wrong
import FileManagerPlugin from 'filemanager-plugin';correctconst { WebpackFilemanager } = require('filemanager-plugin'); - RollupFilemanager wrong
import RollupFilemanager from 'filemanager-plugin';correctconst { RollupFilemanager } = require('filemanager-plugin'); - ViteFilemanager wrong
import { ViteFilemanager } from 'filemanager-plugin';correctconst { ViteFilemanager } = require('filemanager-plugin');
Quickstart
const { WebpackFilemanager } = require('filemanager-plugin');
module.exports = {
plugins: [
new WebpackFilemanager({
events: {
start: {
delete: {
items: ['./dist']
}
},
end: {
zip: {
items: [
{ source: './src/demo0.zip', destination: './dest/demo0', type: 'zip' }
]
}
}
}
})
]
};