{"id":20759,"library":"webpack-exclude-assets-plugin","title":"webpack-exclude-assets-plugin","description":"Webpack 4 plugin to exclude assets from the output bundle based on a path RegExp pattern. Version 0.1.1 is the latest stable release with no further updates since 2018. It is designed to remove unwanted JS files generated alongside extracted CSS/Stylus files when using extract plugins like mini-css-extract-plugin. Lightweight alternative to manual asset filtering in webpack configuration, but only compatible with webpack 4 and does not support webpack 5. Ideal for projects that use style entry points and want to eliminate empty JS output files. Last published 6 years ago; no active maintenance.","status":"maintenance","version":"0.1.1","language":"javascript","source_language":"en","source_url":"git@github.com:klaytonfaria/webpack-exclude-assets-plugin","tags":["javascript","webpack","webpack 4","plugin","exclude","assets","chuncks","path","name"],"install":[{"cmd":"npm install webpack-exclude-assets-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-exclude-assets-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-exclude-assets-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CommonJS is the only supported module system; ESM import may fail depending on bundler config.","wrong":"import ExcludeAssetsPlugin from 'webpack-exclude-assets-plugin';","symbol":"ExcludeAssetsPlugin","correct":"const ExcludeAssetsPlugin = require('webpack-exclude-assets-plugin');"},{"note":"The default export is the constructor; named destructuring will not work.","wrong":"const { ExcludeAssetsPlugin } = require('webpack-exclude-assets-plugin');","symbol":"ExcludeAssetsPlugin","correct":"import ExcludeAssetsPlugin = require('webpack-exclude-assets-plugin');"},{"note":"The package has both a CommonJS default and a named export 'default'; require returns an object with 'default' as the plugin constructor in some environments. Use .default to be safe.","wrong":"const ExcludeAssetsPlugin = require('webpack-exclude-assets-plugin');","symbol":"ExcludeAssetsPlugin","correct":"const ExcludeAssetsPlugin = require('webpack-exclude-assets-plugin').default;"}],"quickstart":{"code":"const path = require('path');\nconst MiniCssExtractPlugin = require('mini-css-extract-plugin');\nconst ExcludeAssetsPlugin = require('webpack-exclude-assets-plugin').default;\n\nmodule.exports = {\n  entry: {\n    app: path.resolve(__dirname, 'js/app.js'),\n    'css/app': path.resolve(__dirname, 'css/app.css')\n  },\n  output: {\n    path: path.join(__dirname, 'dist'),\n    filename: 'js/[name].js'\n  },\n  plugins: [\n    new MiniCssExtractPlugin({ filename: '[name].css' }),\n    new ExcludeAssetsPlugin({\n      path: ['^js\\\\/css\\\\.*\\\\.js$']\n    })\n  ],\n  module: {\n    rules: [\n      {\n        test: /\\.css$/,\n        exclude: /node_modules/,\n        use: [MiniCssExtractPlugin.loader, 'css-loader']\n      }\n    ]\n  },\n  resolve: { extensions: ['.css'] }\n};","lang":"javascript","description":"Configures webpack 4 to exclude empty JS files generated from CSS entries using regex pattern."},"warnings":[{"fix":"Use webpack 4 or find an alternative such as 'webpack-files-archive-plugin' or custom plugin for webpack 5.","message":"Plugin does not work with webpack 5. It relies on internal webpack 4 hooks (compilation.hooks.optimizeAssets) that are removed in webpack 5.","severity":"breaking","affected_versions":">=0.1.1"},{"fix":"Pass a string or array of strings representing the regex pattern. Example: path: ['^js\\\\/css\\\\.*\\\\.js$']","message":"The `path` option expects regex strings, not actual RegExp objects. The plugin throws if you pass a RegExp literal.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Manually escape special regex characters in the path patterns (e.g., use '\\\\.' instead of '.').","message":"The plugin does not handle file extensions with dashes or dots correctly in some regex patterns due to missing escaping.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Migrate to webpack 5 native asset filtering using 'webpack.IgnorePlugin' or 'output.clean' option.","message":"Package has not been updated since 2018 and is considered deprecated for new projects.","severity":"deprecated","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":"Ensure that the plugin is added to the plugins array and that compilation is not deferred. Use synchronous loaders.","cause":"The plugin expects the compilation.assets object to have named keys, but it may be empty or undefined if used asynchronously.","error":"TypeError: Cannot read properties of undefined (reading 'length')"},{"fix":"Convert the RegExp to a string: path: ['^js\\\\/css\\\\.*\\\\.js$']","cause":"Passed a RegExp object instead of a string pattern.","error":"Error: ExcludeAssetsPlugin: path must be a string or an array of strings"},{"fix":"Use default require: const ExcludeAssetsPlugin = require('webpack-exclude-assets-plugin').default;","cause":"Using named import incorrectly (e.g., const { ExcludeAssetsPlugin } = require(...)).","error":"TypeError: excludeAssetsPlugin is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}