{"id":20111,"library":"html-webpack-partials-plugin","title":"html-webpack-partials-plugin","description":"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.","status":"active","version":"0.8.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/colbyfayock/html-webpack-partials-plugin","tags":["javascript","webpack","plugin","html","partial","template","html-webpack-plugin","html-webpack-partials-plugin"],"install":[{"cmd":"npm install html-webpack-partials-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add html-webpack-partials-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add html-webpack-partials-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for integration; must be >=4.3.0","package":"html-webpack-plugin","optional":false}],"imports":[{"note":"CommonJS only; no default ESM export available. Use require().","wrong":"import HtmlWebpackPartialsPlugin from 'html-webpack-partials-plugin';","symbol":"HtmlWebpackPartialsPlugin","correct":"const HtmlWebpackPartialsPlugin = require('html-webpack-partials-plugin');"},{"note":"Exported as a single constructor function, not a named export.","wrong":"const { HtmlWebpackPartialsPlugin } = require('html-webpack-partials-plugin');","symbol":"HtmlWebpackPartialsPlugin","correct":"const HtmlWebpackPartialsPlugin = require('html-webpack-partials-plugin');"},{"note":"Must be instantiated with an object (or array of objects); passing a string directly will fail.","wrong":"new HtmlWebpackPartialsPlugin('./partials/header.html');","symbol":"HtmlWebpackPartialsPlugin","correct":"new HtmlWebpackPartialsPlugin({ path: './partials/header.html' });"}],"quickstart":{"code":"const path = require('path');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\nconst HtmlWebpackPartialsPlugin = require('html-webpack-partials-plugin');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js'\n  },\n  plugins: [\n    new HtmlWebpackPlugin(),\n    new HtmlWebpackPartialsPlugin({\n      path: path.join(__dirname, 'partials', 'ga.html'),\n      location: 'head',\n      priority: 'high',\n      options: { trackingId: process.env.GA_TRACKING_ID ?? '' }\n    })\n  ]\n};","lang":"javascript","description":"Shows a minimal webpack config with partial plugin injecting a analytics snippet into <head> using an environment variable."},"warnings":[{"fix":"Upgrade html-webpack-plugin to 4.3.0 or higher.","message":"Requires html-webpack-plugin >=4.3.0; incompatible with older versions (1.x-3.x).","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Use exact template filename (e.g., 'index.html') or pass an array of strings.","message":"template_filename option does not support regex; only exact string or '*' for all templates. '*.html' will not match.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure partial files contain only raw HTML; use HtmlWebpackPlugin's template for dynamic content.","message":"Partial files must be plain HTML snippets; no template engine (e.g., EJS) processing is applied.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Evaluate migrating to html-webpack-plugin's template option or a more modern replacement.","message":"Plugin is no longer actively maintained; last update 2021. Consider alternatives like html-webpack-plugin's own template feature or separate plugin.","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":"Run 'npm install html-webpack-partials-plugin --save-dev' or 'yarn add html-webpack-partials-plugin -D'.","cause":"Package not installed or missing from node_modules.","error":"Error: Cannot find module 'html-webpack-partials-plugin'"},{"fix":"Use 'const HtmlWebpackPartialsPlugin = require(\"html-webpack-partials-plugin\");' (CommonJS) or ensure webpack config is not bundled.","cause":"Possibly importing a named export incorrectly; the plugin is exported as default.","error":"TypeError: HtmlWebpackPartialsPlugin is not a constructor"},{"fix":"Ensure 'new HtmlWebpackPartialsPlugin({ path: '...' })' is used with an object.","cause":"Plugin instantiation with wrong argument type (e.g., string instead of object).","error":"ValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}