Registry / devops / webpack-cleanup-plugin

webpack-cleanup-plugin

JSON →
library0.5.1jsnpmunverified

Webpack plugin to clean up extraneous files from the output path after compilation. Version 0.5.1 is the latest stable release; the package is no longer actively maintained. It removes files not generated by the current webpack build, useful for production builds to avoid stale assets. Alternatives like clean-webpack-plugin or output.clean (webpack 5+) are preferred. Supports exclude patterns (minimatch globs), quiet mode, and preview mode to list files without deletion.

npm install webpack-cleanup-plugin
INSTALL
IMPORT
SIG · WEBPACK-CLEANUP-PL
W
webpack-cleanup-plugin
devopsjavascriptv0.5.1
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.

WebpackCleanupPlugin
import WebpackCleanupPlugin from 'webpack-cleanup-plugin';
const WebpackCleanupPlugin = require('webpack-cleanup-plugin').default;
Default export is the class; no named export.
WebpackCleanupPlugin
const WebpackCleanupPlugin = require('webpack-cleanup-plugin');
const { WebpackCleanupPlugin } = require('webpack-cleanup-plugin');
CommonJS require returns the constructor directly, not in an object.
WebpackCleanupPlugin
import WebpackCleanupPlugin from 'webpack-cleanup-plugin';
import { WebpackCleanupPlugin } from 'webpack-cleanup-plugin';
It is a default export, not named.

Shows minimal webpack config with webpack-cleanup-plugin that previews files to delete except excluded patterns.

const path = require('path'); const WebpackCleanupPlugin = require('webpack-cleanup-plugin'); module.exports = { output: { path: path.resolve(__dirname, 'dist'), }, plugins: [ new WebpackCleanupPlugin({ exclude: ['stats.json', 'important.js', 'folder/**/*'], quiet: false, preview: true, }), ], };
Debug
Known issues
breakingPlugin deletes files from output directory. Misconfigured exclude may delete important files.
fix
Always use preview: true in development to verify files before deletion. Ensure exclude patterns cover non-webpack assets.
affects: >=0.0.0
gotchaPlugin does not support webpack 5's output.clean option or hooks; may need additional configuration for webpack 5.
fix
Consider using output.clean: true in webpack 5 or migrate to clean-webpack-plugin.
affects: >=0.5.1
gotchaExclude patterns use minimatch globbing; relative paths are relative to output path, not project root.
fix
Use absolute patterns or ensure paths are relative to output.path.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'webpack-cleanup-plugin'
Package not installed or missing from node_modules.
fix
Run npm install webpack-cleanup-plugin --save-dev
TypeError: WebpackCleanupPlugin is not a constructor
Incorrect import style; e.g. named import instead of default.
fix
Use const WebpackCleanupPlugin = require('webpack-cleanup-plugin'); or import WebpackCleanupPlugin from 'webpack-cleanup-plugin';
Error: webpack.CleanupPlugin is not a function
Misunderstood as built-in webpack plugin.
fix
This plugin is separate: install and import webpack-cleanup-plugin.
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies
webpackrequiredRuntime peer dependency; plugin uses webpack compiler hooks
Agent activity
13 hits · last 30 days
node
12
Resources
webpack-cleanup-plugin — npm install webpack-cleanup-plugin · libregistry