{"id":20512,"library":"remove-webpack-plugin","title":"RemoveWebpackPlugin","description":"Plugin for webpack to remove directories or files during the build process, similar to rm -r. Current stable version is 1.2.2. The plugin has low release cadence. It is straightforward but offers minimal features compared to alternatives like CleanWebpackPlugin. It supports removing single or multiple paths and configuring error handling (show, hide, fatal). Only works with webpack plugins API.","status":"active","version":"1.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/aleksei0807/remove-webpack-plugin","tags":["javascript","webpack","plugin","remove","directory","file","rm","rf","recursive"],"install":[{"cmd":"npm install remove-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add remove-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add remove-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package does not export ES modules; use CommonJS require. Only default export available.","wrong":"import RemoveWebpackPlugin from 'remove-webpack-plugin';","symbol":"RemoveWebpackPlugin","correct":"const RemoveWebpackPlugin = require('remove-webpack-plugin');"},{"note":"No named exports; only default import via require.","symbol":"CommonJS require","correct":"const RemoveWebpackPlugin = require('remove-webpack-plugin');"},{"note":"ESM import is not supported; package lacks \"type\": \"module\" and does not provide ESM exports.","wrong":"import RemoveWebpackPlugin from 'remove-webpack-plugin';","symbol":"ESM syntax","correct":"const RemoveWebpackPlugin = require('remove-webpack-plugin');"}],"quickstart":{"code":"const RemoveWebpackPlugin = require('remove-webpack-plugin');\n\nmodule.exports = {\n  plugins: [\n    new RemoveWebpackPlugin(['./public/', './build/'], { errors: 'hide' })\n  ]\n}","lang":"javascript","description":"Shows how to configure RemoveWebpackPlugin to remove multiple directories and suppress warnings."},"warnings":[{"fix":"Use const RemoveWebpackPlugin = require('remove-webpack-plugin');","message":"Use default export only; named imports will cause errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure paths like './public/' are correct relative to process.cwd().","message":"Paths are relative to the project root, not the output directory.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use CleanWebpackPlugin if glob support is needed.","message":"The plugin does not handle glob patterns; specify exact paths.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use require('remove-webpack-plugin') instead of import.","cause":"Using import statement that returns default as an object instead of function.","error":"TypeError: RemoveWebpackPlugin is not a constructor"},{"fix":"Adjust paths to be relative to the project root, or ensure directories exist.","cause":"Removing a path that is not relative to project root or does not exist.","error":"Error: ENOENT: no such file or directory, lstat './dist'"},{"fix":"Use { errors: 'show' } to see error messages.","cause":"Plugin may be configured with errors: 'hide' and fails silently.","error":"Plugin attempted to remove files but nothing happened"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}