Registry / web-framework / rollup-plugin-html

rollup-plugin-html

JSON →
library0.2.1jsnpmunverified

A Rollup plugin that imports HTML files as JavaScript string variables. Version 0.2.1 is the latest stable release, though the project appears to be in maintenance mode with no recent updates. It uses rollup-pluginutils for file filtering and integrates with html-minifier for optional minification. Differentiators: simple API, support for include/exclude glob patterns, and opt-in HTML minification via html-minifier options. Alternatives like @rollup/plugin-html or vite-plugin-html offer more features.

npm install rollup-plugin-html
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-HTML
R
rollup-plugin-html
web-frameworkjavascriptv0.2.1
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.

default
import html from 'rollup-plugin-html'
const html = require('rollup-plugin-html')
ESM default export. CJS require works but returns default export.
html
import html from 'rollup-plugin-html'
import { html } from 'rollup-plugin-html'
Named import 'html' does not exist; only default export.
rollup-plugin-html
const html = require('rollup-plugin-html');
const { default: html } = require('rollup-plugin-html')
In CJS, require returns the default export directly.

Shows how to configure rollup-plugin-html in a rollup config and import an HTML file as a string.

// rollup.config.js import html from 'rollup-plugin-html'; export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'iife' }, plugins: [ html({ include: '**/*.html', exclude: '**/excluded.html', htmlMinifierOptions: { collapseWhitespace: true } }) ] }; // main.js import template from './template.html'; document.body.innerHTML = template;
Debug
Known issues
deprecatedThe package is in maintenance mode; no recent updates and may not work with Rollup 3+.
fix
Consider migrating to @rollup/plugin-html or use vite-plugin-html for modern builds.
affects: >=0.2.1
gotchaThe plugin does not handle SVG files or non-HTML XML; only .html extensions.
fix
Use a separate plugin for SVG or XML imports.
affects: >=0.1.0
gotchahtmlMinifierOptions are passed directly to html-minifier; invalid options may cause errors.
fix
Ensure options match html-minifier documentation.
affects: >=0.1.0
gotchaThe include default is '**/*.html' but excludes node_modules by default; custom include patterns must explicitly include node_modules if needed.
fix
Set include option to include node_modules: include: ['**/*.html', 'node_modules/**/*.html']
affects: >=0.1.0
Errors
Common errors & fixes
Error: Could not resolve module 'rollup-plugin-html'
Package not installed or incorrect import path.
fix
Run npm install --save-dev rollup-plugin-html and ensure correct import syntax.
TypeError: html is not a function
Using named import instead of default import.
fix
Use import html from 'rollup-plugin-html' rather than import { html } from 'rollup-plugin-html'.
ReferenceError: html is not defined
Plugin not included in rollup config plugins array.
fix
Add html() to the plugins array in rollup.config.js.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
rollup-pluginutilsrequiredUsed for file filtering (include/exclude patterns)
html-minifieroptionalOptional HTML minification
Agent activity
2 hits · last 30 days
node
2
Resources
rollup-plugin-html — npm install rollup-plugin-html · libregistry