{"id":20508,"library":"remove-source-webpack-plugin","title":"Remove Source Webpack Plugin","description":"A lightweight webpack plugin that removes specified assets from the compilation output, commonly used in conjunction with html-webpack-inline-source-plugin to eliminate inlined source files from the final bundle. The current version is 0.1.1. It accepts regex or an array of regex patterns to match assets for removal. The plugin is available as an npm package under an MIT license.","status":"active","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/yangmingshan/remove-source-webpack-plugin","tags":["javascript","remove","delete","ignore","clean","source","assets","webpack","plugin"],"install":[{"cmd":"npm install remove-source-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add remove-source-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add remove-source-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import works, but the package is CommonJS by default; require is safe for all environments","wrong":"import RemoveSourceWebpackPlugin from 'remove-source-webpack-plugin'","symbol":"RemoveSourceWebpackPlugin","correct":"const RemoveSourceWebpackPlugin = require('remove-source-webpack-plugin')"},{"note":"Default export is the class itself, no .default needed","wrong":"const plugin = require('remove-source-webpack-plugin').default","symbol":"default export","correct":"const RemoveSourceWebpackPlugin = require('remove-source-webpack-plugin')"},{"note":"Named import fails because it's a default export","wrong":"import { RemoveSourceWebpackPlugin } from 'remove-source-webpack-plugin'","symbol":"alias import","correct":"import RemoveSourceWebpackPlugin from 'remove-source-webpack-plugin'"}],"quickstart":{"code":"const RemoveSourceWebpackPlugin = require('remove-source-webpack-plugin');\n\nmodule.exports = {\n  // ... other webpack config\n  plugins: [\n    new RemoveSourceWebpackPlugin(/runtime\\..*\\.js$/),\n  ],\n};","lang":"javascript","description":"Shows how to require and instantiate the plugin with a regex pattern to remove runtime chunk files."},"warnings":[{"fix":"Ensure webpack version is 4 or 5.","message":"Plugin only works in webpack 4 and 5, not webpack 3.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Provide regex patterns that match asset filenames, not paths.","message":"Using an empty array or no patterns removes nothing; patterns must match asset names exactly.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"It works after emit hooks, so removed assets won't appear in output directory.","message":"The plugin removes assets from compilation, not from the file system.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"You can add multiple instances with different patterns.","message":"Multiple plugins of same type can be added; each removes matching assets.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Upgrade to webpack 4 or 5.","cause":"Webpack version mismatch (e.g., webpack 3)","error":"TypeError: Super expression must either be null or a function"},{"fix":"Use default import: const RemoveSourceWebpackPlugin = require('remove-source-webpack-plugin');","cause":"Attempted to import using named import 'RemoveSourceWebpackPlugin'","error":"ERROR: RemoveSourceWebpackPlugin is not a constructor"},{"fix":"Run `npm install remove-source-webpack-plugin --save-dev`.","cause":"Package not installed or webpack config path issue","error":"Module not found: Error: Can't resolve 'remove-source-webpack-plugin'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}