Registry / devops / rollup-plugin-html-minifier

rollup-plugin-html-minifier

JSON →
library2.0.0jsnpmunverified

Rollup plugin that minifies HTML files in the bundle using html-minifier. Current stable version: 2.0.0. Release cadence: low, with infrequent updates. Key differentiators: simple integration with Rollup, supports glob patterns for inclusion/exclusion, and exposes all html-minifier options. Alternative plugins like @rollup/plugin-html focus on HTML generation rather than minification. Note that most html-minifier options are disabled by default, requiring explicit configuration for actual minification.

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

htmlMinifier
import htmlMinifier from 'rollup-plugin-html-minifier'
const htmlMinifier = require('rollup-plugin-html-minifier')
Default export; ESM-only. CommonJS require will fail in Node.js without ESM support.
PluginOptions
import type { PluginOptions } from 'rollup-plugin-html-minifier'
import { PluginOptions } from 'rollup-plugin-html-minifier' (if used as value)
TypeScript type export, not a value.
htmlMinifier (with options object)
import htmlMinifier from 'rollup-plugin-html-minifier'; htmlMinifier({ include: '*.html', options: { removeComments: true } })
htmlMinifier() without options (no minification occurs as defaults are mostly disabled)
Passing an empty options object results in no minification; html-minifier options must be explicitly enabled.

Minifies all HTML files matched by the glob pattern, enabling several html-minifier options for effective compression.

// rollup.config.js import htmlMinifier from 'rollup-plugin-html-minifier'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'esm', }, plugins: [ htmlMinifier({ include: '*.html', options: { removeComments: true, collapseWhitespace: true, removeAttributeQuotes: true, minifyJS: true, minifyCSS: true, }, }), ], };
Debug
Known issues
breakingVersion 2.0.0 requires Rollup >= 2.10.0; older Rollup versions will break.
fix
Upgrade Rollup to version 2.10.0 or later.
affects: >=2.0.0
gotchaMost html-minifier options are disabled by default; passing an empty options object yields no minification.
fix
Set desired options explicitly, e.g., options.collapseWhitespace: true.
affects: >=0.0.0
gotchaThe plugin does not process files that are not emitted or transformed by Rollup; include/exclude patterns only filter within Rollup's asset pipeline.
fix
Ensure HTML files are part of the Rollup bundle (e.g., through @rollup/plugin-html or a manual emit).
affects: >=0.0.0
Errors
Common errors & fixes
Error: Could not resolve 'rollup-plugin-html-minifier'
Package not installed or missing from node_modules.
fix
Run npm install rollup-plugin-html-minifier --save-dev
TypeError: htmlMinifier is not a function
Using CommonJS require() on a package that exports ESM only.
fix
Use import syntax or configure Node.js to handle ESM (e.g., type: 'module' in package.json).
The emitted file 'index.html' is empty after build
html-minifier options are all disabled; no minification applied, but content may also be missing if the plugin didn't process the file.
fix
Ensure the HTML file is included in Rollup's bundle and pass explicit options like { removeComments: true }.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
rolluprequiredpeer dependency for plugin functionality
Agent activity
7 hits · last 30 days
node
6
Resources
rollup-plugin-html-minifier — npm install rollup-plugin-html-minifier · libregistry