Registry / devops / remove-files-webpack-plugin

remove-files-webpack-plugin

JSON →
library1.5.0jsnpmunverified

A webpack plugin for removing files and folders before and after compilation. Current stable version is 1.5.0, released 2021-04-12. Supports webpack >= 2.2.0 and Node >= 8.3.0. Ships TypeScript types. Key differentiators: supports before, after, and watch compilation modes; handles symbolic links as ordinary files; works on all OS with platform-specific path handling. Unlike clean-webpack-plugin, it allows granular control over which files to remove and supports watch mode cleanup. Development appears dormant since 2021.

npm install remove-files-webpack-plugin
INSTALL
IMPORT
SIG · REMOVE-FILES-WEBPA
R
remove-files-webpack-plugin
devopsjavascriptv1.5.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RemovePlugin
const RemovePlugin = require('remove-files-webpack-plugin');
import RemovePlugin from 'remove-files-webpack-plugin';
Package does not ship ESM exports; only CommonJS is supported. TypeScript users may use `import RemovePlugin = require('remove-files-webpack-plugin')` for compatibility.
RemovePlugin
import RemovePlugin = require('remove-files-webpack-plugin');
import { RemovePlugin } from 'remove-files-webpack-plugin';
Use TypeScript import equals syntax for correct type resolution. The named import pattern is not supported.
RemovePlugin
new RemovePlugin({ before: { include: ['dist'] } })
new RemovePlugin({ include: ['dist'] })
The plugin expects a configuration object with `before`, `watch`, or `after` namespaces, not flat options.

Demonstrates removing the 'dist' folder before compilation and a 'temp' folder after compilation using the before and after namespaces.

const RemovePlugin = require('remove-files-webpack-plugin'); module.exports = { context: __dirname, entry: './src/index.js', output: { path: './dist', filename: 'bundle.js' }, plugins: [ new RemovePlugin({ before: { include: ['./dist'], allowRoot: false }, after: { include: ['./dist/temp'] } }) ] };
Debug
Known issues
gotchaPlugin configuration must be nested under `before`, `watch`, or `after` namespaces; flat configuration with `include` at root will be silently ignored.
fix
Wrap options in the appropriate namespace: `new RemovePlugin({ before: { include: [...] } })`.
affects: >=1.0.0
gotchaPaths in `include` and `exclude` are resolved relative to the plugin's `root` option (defaults to webpack's context, typically `.`). Do not assume they are relative to the project root.
fix
Set the `root` option explicitly or use absolute paths.
affects: >=1.0.0
breakingVersion 1.4.0 changed the default root from the current working directory to the webpack context (process.cwd()). Projects relying on the old default may delete the wrong files.
fix
Explicitly set `root: process.cwd()` if the previous behavior was desired.
affects: 1.4.0 - 1.5.0
deprecatedThe `allowRoot` option (default `false`) is deprecated and may be removed in a future major version.
fix
Avoid using `allowRoot: true`; ensure `include` and `exclude` paths are subdirectories of `root`.
affects: >=1.3.0
Errors
Common errors & fixes
Error: The plugin must be constructed with an object containing 'before', 'watch', or 'after' namespaces.
Passing flat configuration like `new RemovePlugin({ include: ['dist'] })`.
fix
Wrap options: `new RemovePlugin({ before: { include: ['dist'] } })`.
Cannot read property 'tapAsync' of undefined
Using an unsupported webpack version (e.g., webpack 5 without compatibility layer).
fix
Upgrade to webpack 5 compatible version of the plugin or use webpack 4.
TypeError: Cannot read property 'root' of undefined
Omitting the options object entirely (e.g., `new RemovePlugin()`) or passing `null`.
fix
Provide at least one namespace: `new RemovePlugin({ after: { include: [] } })`.
Upgrade
Version history
1.5.0latest on npm
Audit
Dependencies
webpackrequiredpeer dependency; plugin integrates with webpack compilation hooks
Agent activity
6 hits · last 30 days
node
6
Resources
remove-files-webpack-plugin — npm install remove-files-webpack-plugin · libregistry