Rollup plugin to inject bundled JavaScript/CSS files into an HTML template. Current stable version is 4.0.0. It reads output from Rollup's bundle rather than scanning the file system, and emits the HTML as an asset for other plugins to use. Supports customization via template, filename, title, meta tags, and asset injection order. Requires Rollup >=3.0 and has an optional peer dependency on html-minifier. Licensed under MIT.
npm install rollup-plugin-html2Verified import paths — ran on the pinned version, not inferred.
Shows basic integration: import the default export and use it in a Rollup config with a custom template and output filename.
Update templates to not expect a leading slash in asset paths.
Upgrade Rollup to version 3 or later.
Reorder plugins: favicons first, then html2.
Replace `inject: true` with `inject: 'head'` and `hash: true` with a custom filename pattern.
Upgrade Rollup to version 3 or higher, or downgrade rollup-plugin-html2 to v2.x.
Use `import html2 from 'rollup-plugin-html2'` (default import) instead of `import { html2 } from 'rollup-plugin-html2'`.Run `npm i -D rollup-plugin-html2` and ensure using the correct import (default import for ESM or `const html2 = require('rollup-plugin-html2')` for CJS).