Registry / devops / rollup-plugin-html2

rollup-plugin-html2

JSON →
library4.0.0jsnpmunverified

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-html2
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-HTML
R
rollup-plugin-html2
devopsjavascriptv4.0.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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

html2
import html2 from 'rollup-plugin-html2'
import { html2 } from 'rollup-plugin-html2'
Default export, not named.
default
const html2 = require('rollup-plugin-html2')
const { html2 } = require('rollup-plugin-html2')
For CJS via require, use default import pattern.
PluginOptions
import type { PluginOptions } from 'rollup-plugin-html2'
import { PluginOptions } from 'rollup-plugin-html2'
Type import only, not a runtime value.

Shows basic integration: import the default export and use it in a Rollup config with a custom template and output filename.

import html2 from 'rollup-plugin-html2'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'es', }, plugins: [ html2({ template: 'src/template.html', filename: 'index.html', title: 'My App', }), ], };
Debug
Known issues
breakingVersion 2.0.0 stopped prefixing file paths with '/'
fix
Update templates to not expect a leading slash in asset paths.
affects: >=2.0.0
breakingVersion 3.0.0 requires Rollup >=3.0
fix
Upgrade Rollup to version 3 or later.
affects: >=3.0.0
gotcharollup-plugin-favicons must be placed before rollup-plugin-html2 in plugins array
fix
Reorder plugins: favicons first, then html2.
affects: >=0.1.0
deprecatedOptions `inject` and `hash` are deprecated; use `fileName` and `publicPath` instead
fix
Replace `inject: true` with `inject: 'head'` and `hash: true` with a custom filename pattern.
affects: >=4.0.0
Errors
Common errors & fixes
Error: The plugin 'rollup-plugin-html2' is not compatible with Rollup <3.0
Using rollup-plugin-html2 version >=3.0.0 with an older Rollup version
fix
Upgrade Rollup to version 3 or higher, or downgrade rollup-plugin-html2 to v2.x.
TypeError: html2 is not a function
Importing as a named export instead of default export
fix
Use `import html2 from 'rollup-plugin-html2'` (default import) instead of `import { html2 } from 'rollup-plugin-html2'`.
Error: Could not resolve 'rollup-plugin-html2'
Package not installed or imported incorrectly in a CommonJS context
fix
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).
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
rolluprequiredpeer dependency: required to work as a Rollup plugin
@types/html-minifieroptionaloptional peer dependency for TypeScript users
Agent activity
7 hits · last 30 days
node
6
Resources
rollup-plugin-html2 — npm install rollup-plugin-html2 · libregistry