{"id":20114,"library":"html-webpack-skip-assets-plugin","title":"HtmlWebpackSkipAssetsPlugin","description":"A webpack plugin that works with html-webpack-plugin (>=3.0.0) to skip adding certain output files (chunks, assets) to the generated HTML. Current version 1.0.4, maintained, compatible with webpack 3–5. Acts as a drop-in replacement for the unmaintained html-webpack-exclude-assets-plugin. Supports glob patterns (minimatch), regex, or callback functions to filter assets. Allows configuration on either HtmlWebpackPlugin options or plugin constructor. Fixes CVEs and global regex issues in prior versions.","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/swimmadude66/html-webpack-skip-assets-plugin","tags":["javascript","html-webpack-plugin","exclude-assets","assets","polyfills","webpack","plugin"],"install":[{"cmd":"npm install html-webpack-skip-assets-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add html-webpack-skip-assets-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add html-webpack-skip-assets-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency - hooks into its lifecycle to filter assets","package":"html-webpack-plugin","optional":false},{"reason":"peer dependency - operates as a webpack plugin","package":"webpack","optional":false}],"imports":[{"note":"The plugin is a named export, not default. CommonJS requires destructuring.","wrong":"const HtmlWebpackSkipAssetsPlugin = require('html-webpack-skip-assets-plugin');","symbol":"HtmlWebpackSkipAssetsPlugin","correct":"const { HtmlWebpackSkipAssetsPlugin } = require('html-webpack-skip-assets-plugin');"},{"note":"ESM named import. No default export exists.","symbol":"HtmlWebpackSkipAssetsPlugin","correct":"import { HtmlWebpackSkipAssetsPlugin } from 'html-webpack-skip-assets-plugin';"},{"note":"Plugin must be instantiated after HtmlWebpackPlugin in the plugins array.","symbol":"HtmlWebpackSkipAssetsPlugin","correct":"new HtmlWebpackSkipAssetsPlugin({ skipAssets: ['polyfill.*.js'] })"}],"quickstart":{"code":"const HtmlWebpackPlugin = require('html-webpack-plugin');\nconst { HtmlWebpackSkipAssetsPlugin } = require('html-webpack-skip-assets-plugin');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: { path: './dist', filename: '[name].[contenthash].js' },\n  plugins: [\n    new HtmlWebpackPlugin({ template: './src/index.html' }),\n    new HtmlWebpackSkipAssetsPlugin({\n      skipAssets: ['polyfill.*.js', /styles\\..*\\.js$/i]\n    })\n  ]\n};","lang":"javascript","description":"Shows minimal webpack config with HtmlWebpackSkipAssetsPlugin to exclude polyfill and style JS files from the HTML output."},"warnings":[{"fix":"Upgrade webpack to >=3 and html-webpack-plugin to >=3.","message":"In v1.0.0, support for webpack <3 and html-webpack-plugin <3 was dropped.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always list HtmlWebpackPlugin first, then HtmlWebpackSkipAssetsPlugin.","message":"The plugin must be added AFTER HtmlWebpackPlugin in the plugins array. Order matters.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Replace excludeAssets with skipAssets in plugin configuration.","message":"Using the excludeAssets option is deprecated in favor of skipAssets but still supported for migration.","severity":"deprecated","affected_versions":">=0.0.1"},{"fix":"Use minimatch glob syntax (e.g., 'polyfill.**.js' not 'polyfill.*.js').","message":"Glob patterns use minimatch, not webpack's test pattern syntax. Double-check patterns.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Access asset.tagName and asset.attributes, not the filename directly.","message":"Callback functions receive an HtmlTagObject from html-webpack-plugin, not the asset filename string.","severity":"gotcha","affected_versions":">=1.0.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Update to version 1.0.2 or later.","cause":"Meta assets with null/undefined src or href attributes cause errors in earlier versions.","error":"TypeError: Cannot read properties of undefined (reading 'src')"},{"fix":"Use destructured import: const { HtmlWebpackSkipAssetsPlugin } = require(...);","cause":"Importing the module incorrectly (assuming default export).","error":"Uncaught Error: HtmlWebpackSkipAssetsPlugin is not a constructor"},{"fix":"Place HtmlWebpackSkipAssetsPlugin after HtmlWebpackPlugin in the plugins array.","cause":"Plugin order in the plugins array is incorrect.","error":"ERROR in HtmlWebpackSkipAssetsPlugin: Plugin must be used after HtmlWebpackPlugin"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}