{"id":13322,"library":"ignore-emit-webpack-plugin","title":"Ignore Emit Webpack Plugin","description":"The `ignore-emit-webpack-plugin` is a Webpack plugin designed to prevent specific assets from being emitted to the output directory during the build process. Unlike other methods that might merely filter assets during compilation, this plugin explicitly operates on the final output path, providing precise control over what actually gets written to disk. Currently at version 2.0.6, the library demonstrates a moderate release cadence, addressing compatibility issues (e.g., with Webpack 4, Terser, SourceMapDevTools) and adding support for newer Webpack versions (e.g., Webpack 5). It differentiates itself by offering flexible pattern matching (RegExp, string, or arrays) against the *output* path of assets, and since v2.0.2, it is rewritten in TypeScript, offering improved type safety and maintainability for modern JavaScript ecosystems.","status":"active","version":"2.0.6","language":"javascript","source_language":"en","source_url":"https://github.com/mrbar42/ignore-emit-webpack-plugin","tags":["javascript","webpack","plugin","ignore","emit","asset","assets"],"install":[{"cmd":"npm install ignore-emit-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add ignore-emit-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add ignore-emit-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The plugin is a default export. Named imports like `{ IgnoreEmitPlugin }` are incorrect.","wrong":"import { IgnoreEmitPlugin } from 'ignore-emit-webpack-plugin';","symbol":"IgnoreEmitPlugin","correct":"import IgnoreEmitPlugin from 'ignore-emit-webpack-plugin';"},{"note":"For CommonJS environments, `require` returns the default export directly. Named destructuring is incorrect.","wrong":"const { IgnoreEmitPlugin } = require('ignore-emit-webpack-plugin');","symbol":"IgnoreEmitPlugin (CommonJS)","correct":"const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin');"},{"note":"Use this specific path if your environment requires an ES5-transpiled version of the module, though the main export should work for most modern Node.js versions.","symbol":"IgnoreEmitPlugin (ES5 build)","correct":"const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin/es5');"}],"quickstart":{"code":"// webpack.config.js\nimport IgnoreEmitPlugin from 'ignore-emit-webpack-plugin';\n\nexport default {\n  mode: 'development',\n  entry: './src/index.js',\n  output: {\n    filename: 'bundle.js',\n    path: new URL('./dist', import.meta.url).pathname,\n  },\n  plugins: [\n    // This will prevent any generated .map files from being emitted to the output directory.\n    new IgnoreEmitPlugin(/\\.map$/),\n    // To prevent a specific asset, e.g., 'licenses.txt', after it's been generated by another plugin.\n    // Note: The pattern matches against the output path, e.g., 'licenses.txt' for a file in the root of 'dist'.\n    new IgnoreEmitPlugin('licenses.txt')\n  ]\n};","lang":"typescript","description":"Demonstrates how to import and register the plugin in a Webpack configuration to prevent source map files and a specific license file from being emitted."},"warnings":[{"fix":"Start with specific patterns and gradually broaden them if necessary. Use `options.debug: true` to observe what files are being matched without actually preventing their emission first.","message":"Careless use of patterns can lead to accidental deletion of critical output files. Always thoroughly test your patterns to ensure only intended assets are ignored.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to the latest `ignore-emit-webpack-plugin` (v2.0.4+) to ensure full Webpack 5 support and critical bug fixes for Webpack 4.","message":"Older versions of the plugin (prior to v2.0.4 and v2.0.5) may have limited or no compatibility with Webpack 5, or specific bugs when used with Webpack 4.","severity":"breaking","affected_versions":"<2.0.4"},{"fix":"Inspect your Webpack build stats to confirm the exact output paths of the assets you intend to ignore, then adjust your regular expressions or string patterns accordingly.","message":"The plugin's patterns match against the *output path* of assets, not their source paths. Misunderstanding this can lead to patterns failing to match any assets.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure you are using `ignore-emit-webpack-plugin` v2.0.6 or newer to resolve known compatibility problems with common Webpack plugins.","message":"Versions prior to v2.0.6 had known compatibility issues with other Webpack plugins, specifically Terser and SourceMapDevTools, which could lead to unexpected build failures or incorrect output.","severity":"gotcha","affected_versions":"<2.0.6"},{"fix":"If encountering issues after upgrading from a pre-v2.0.2 version, consult the README for correct import statements and ensure your patterns are valid.","message":"The package was rewritten in TypeScript in v2.0.2. While CJS and ESM imports are supported, internal structures or behaviors might have subtly changed for users relying on undocumented internals from pre-v2.0.2 versions.","severity":"gotcha","affected_versions":"<2.0.2"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Provide a valid `RegExp`, `string`, or `Array<RegExp|string>` as the first argument to the plugin constructor, e.g., `new IgnoreEmitPlugin(/\\.map$/)`.","cause":"The `IgnoreEmitPlugin` was instantiated without a `patterns` argument or with an invalid type for the argument.","error":"Error: Plugin initialization failed: patterns must be defined and valid."},{"fix":"Verify the exact output path of the asset you wish to ignore by examining your Webpack build output or stats. Adjust your plugin pattern to precisely match this output path. Remember patterns like `^file.js` match the start of the path, while `/file.js` matches anywhere.","cause":"The provided pattern does not correctly match the asset's final output path, or the pattern is being applied to the source path instead of the emitted asset's path.","error":"Asset still emitted despite IgnoreEmitPlugin being configured."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}