Registry / devops / html-webpack-partials-plugin

html-webpack-partials-plugin

JSON →
library0.8.0jsnpmunverified

Extends HTML Webpack Plugin (v4+) to inject HTML partials (e.g., headers, footers, analytics snippets) into webpack-generated HTML files. Version 0.8.0 is the latest stable release. Unlike manual template manipulation, it allows declarative partial injection via plugin options with fine-grained control over injection location (<head>/<body>), priority (prepend/append/replace), and per-template targeting. Supports multiple partials with independent settings.

npm install html-webpack-partials-plugin
INSTALL
IMPORT
SIG · HTML-WEBPACK-PARTI
H
html-webpack-partials-plugin
devopsjavascriptv0.8.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HtmlWebpackPartialsPlugin
const HtmlWebpackPartialsPlugin = require('html-webpack-partials-plugin');
import HtmlWebpackPartialsPlugin from 'html-webpack-partials-plugin';
CommonJS only; no default ESM export available. Use require().
HtmlWebpackPartialsPlugin
const HtmlWebpackPartialsPlugin = require('html-webpack-partials-plugin');
const { HtmlWebpackPartialsPlugin } = require('html-webpack-partials-plugin');
Exported as a single constructor function, not a named export.
HtmlWebpackPartialsPlugin
new HtmlWebpackPartialsPlugin({ path: './partials/header.html' });
new HtmlWebpackPartialsPlugin('./partials/header.html');
Must be instantiated with an object (or array of objects); passing a string directly will fail.

Shows a minimal webpack config with partial plugin injecting a analytics snippet into <head> using an environment variable.

const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPartialsPlugin = require('html-webpack-partials-plugin'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' }, plugins: [ new HtmlWebpackPlugin(), new HtmlWebpackPartialsPlugin({ path: path.join(__dirname, 'partials', 'ga.html'), location: 'head', priority: 'high', options: { trackingId: process.env.GA_TRACKING_ID ?? '' } }) ] };
Debug
Known issues
breakingRequires html-webpack-plugin >=4.3.0; incompatible with older versions (1.x-3.x).
fix
Upgrade html-webpack-plugin to 4.3.0 or higher.
affects: >=0.1.0
gotchatemplate_filename option does not support regex; only exact string or '*' for all templates. '*.html' will not match.
fix
Use exact template filename (e.g., 'index.html') or pass an array of strings.
affects: >=0.1.0
gotchaPartial files must be plain HTML snippets; no template engine (e.g., EJS) processing is applied.
fix
Ensure partial files contain only raw HTML; use HtmlWebpackPlugin's template for dynamic content.
affects: >=0.1.0
deprecatedPlugin is no longer actively maintained; last update 2021. Consider alternatives like html-webpack-plugin's own template feature or separate plugin.
fix
Evaluate migrating to html-webpack-plugin's template option or a more modern replacement.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'html-webpack-partials-plugin'
Package not installed or missing from node_modules.
fix
Run 'npm install html-webpack-partials-plugin --save-dev' or 'yarn add html-webpack-partials-plugin -D'.
TypeError: HtmlWebpackPartialsPlugin is not a constructor
Possibly importing a named export incorrectly; the plugin is exported as default.
fix
Use 'const HtmlWebpackPartialsPlugin = require("html-webpack-partials-plugin");' (CommonJS) or ensure webpack config is not bundled.
ValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
Plugin instantiation with wrong argument type (e.g., string instead of object).
fix
Ensure 'new HtmlWebpackPartialsPlugin({ path: '...' })' is used with an object.
Upgrade
Version history
0.8.0latest on npm
Audit
Dependencies
html-webpack-pluginrequiredpeer dependency required for integration; must be >=4.3.0
Agent activity
4 hits · last 30 days
node
4
Resources
html-webpack-partials-plugin — npm install html-webpack-partials-plugin · libregistry