{"id":20721,"library":"webpack-cleanup-plugin","title":"webpack-cleanup-plugin","description":"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.","status":"maintenance","version":"0.5.1","language":"javascript","source_language":"en","source_url":"https://github.com/gpbl/webpack-cleanup-plugin","tags":["javascript","webpack","webpack-plugin"],"install":[{"cmd":"npm install webpack-cleanup-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-cleanup-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-cleanup-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime peer dependency; plugin uses webpack compiler hooks","package":"webpack","optional":false}],"imports":[{"note":"Default export is the class; no named export.","wrong":"const WebpackCleanupPlugin = require('webpack-cleanup-plugin').default;","symbol":"WebpackCleanupPlugin","correct":"import WebpackCleanupPlugin from 'webpack-cleanup-plugin';"},{"note":"CommonJS require returns the constructor directly, not in an object.","wrong":"const { WebpackCleanupPlugin } = require('webpack-cleanup-plugin');","symbol":"WebpackCleanupPlugin","correct":"const WebpackCleanupPlugin = require('webpack-cleanup-plugin');"},{"note":"It is a default export, not named.","wrong":"import { WebpackCleanupPlugin } from 'webpack-cleanup-plugin';","symbol":"WebpackCleanupPlugin","correct":"import WebpackCleanupPlugin from 'webpack-cleanup-plugin';"}],"quickstart":{"code":"const path = require('path');\nconst WebpackCleanupPlugin = require('webpack-cleanup-plugin');\n\nmodule.exports = {\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n  },\n  plugins: [\n    new WebpackCleanupPlugin({\n      exclude: ['stats.json', 'important.js', 'folder/**/*'],\n      quiet: false,\n      preview: true,\n    }),\n  ],\n};","lang":"javascript","description":"Shows minimal webpack config with webpack-cleanup-plugin that previews files to delete except excluded patterns."},"warnings":[{"fix":"Always use preview: true in development to verify files before deletion. Ensure exclude patterns cover non-webpack assets.","message":"Plugin deletes files from output directory. Misconfigured exclude may delete important files.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Consider using output.clean: true in webpack 5 or migrate to clean-webpack-plugin.","message":"Plugin does not support webpack 5's output.clean option or hooks; may need additional configuration for webpack 5.","severity":"gotcha","affected_versions":">=0.5.1"},{"fix":"Use absolute patterns or ensure paths are relative to output.path.","message":"Exclude patterns use minimatch globbing; relative paths are relative to output path, not project root.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install webpack-cleanup-plugin --save-dev","cause":"Package not installed or missing from node_modules.","error":"Error: Cannot find module 'webpack-cleanup-plugin'"},{"fix":"Use const WebpackCleanupPlugin = require('webpack-cleanup-plugin'); or import WebpackCleanupPlugin from 'webpack-cleanup-plugin';","cause":"Incorrect import style; e.g. named import instead of default.","error":"TypeError: WebpackCleanupPlugin is not a constructor"},{"fix":"This plugin is separate: install and import webpack-cleanup-plugin.","cause":"Misunderstood as built-in webpack plugin.","error":"Error: webpack.CleanupPlugin is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}