A webpack plugin that extends html-webpack-plugin to inject custom JS, CSS, or arbitrary tags (scripts, links, meta, etc.) into the generated HTML. Version 3.0.2 is the latest stable release, released on an irregular cadence. The plugin supports both appending and prepending assets, glob patterns for dynamic asset inclusion, and custom attributes on injected tags. It ships TypeScript types and requires webpack 5 and html-webpack-plugin 5 as peer dependencies. Key differentiator: unlike html-webpack-plugin's built-in asset injection, this plugin allows injecting files not tracked by webpack's compilation (e.g., copied via copy-webpack-plugin) and non-standard tags.
npm install html-webpack-tags-pluginVerified import paths — ran on the pinned version, not inferred.
Shows how to configure HtmlWebpackTagsPlugin with external scripts, local CSS, and a meta tag, with append mode and public path enabled.
Use the new 'tags' array with objects containing 'tagName', 'path', 'attributes', etc. See migration guide.
Use const HtmlWebpackTagsPlugin = require('html-webpack-tags-plugin').default;Set 'publicPath: true/false' in the plugin options object, or omit it per tag.
Use 'append: true' to append after auto assets, or control order via multiple plugin instances.
Set 'publicPath: true' in the plugin options to prepend the webpack publicPath to relative tag paths.
Use const HtmlWebpackTagsPlugin = require('html-webpack-tags-plugin').default;Ensure each tag is an object with at least 'tagName' and optionally 'path' and 'attributes'. Example: { tagName: 'script', path: 'app.js' }Run 'npm install --save-dev html-webpack-tags-plugin' and ensure it is in the devDependencies.
Use a static string or a variable that resolves to a known path. Avoid using expressions like `path: require('path').join(__dirname, 'file.js')` directly in the options object.