Registry /
web-framework / rollup-plugin-minify-html-literals
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ import minifyHTML from 'rollup-plugin-minify-html-literals'
✗ const minifyHTML = require('rollup-plugin-minify-html-literals')
ESM-only package; CommonJS require() fails. Use dynamic import() if needed.
default
✓ const minifyHTML = require('rollup-plugin-minify-html-literals')
✗ import { minifyHTML } from 'rollup-plugin-minify-html-literals'
The package exports a single function as default; named import will be undefined.
type definitions
✓ import type { Options } from 'rollup-plugin-minify-html-literals'
TypeScript types are shipped; you can import types for Options.
Rollup configuration demonstrating how to use the plugin with include option and custom shouldMinify for Polymer templates.
import minifyHTML from 'rollup-plugin-minify-html-literals';
export default {
input: 'src/index.js',
output: { file: 'dist/bundle.js', format: 'iife' },
plugins: [
minifyHTML({
include: 'src/**/*.js',
options: {
shouldMinify: (template) => {
return template.parts.some(p => p.text.includes('<style') || p.text.includes('<dom-module'));
}
}
})
]
};
Debug
Known issues
breakingRollup peer dependency was ^0.65.2 in v1.0.0, then updated to support ^2.0.0 in later 1.x releases. Plugin may not work with Rollup 3 or 4.fixUse Rollup 2 or lower, or switch to an alternative like @rollup/plugin-minify-html-literals.
affects: <1.6.0? (need to check actual peer dep range, but as of 1.2.6 it's '^0.65.2 || ^1.0.0 || ^2.0.0')
gotchaThe plugin must be placed before transpilers (Babel) and other minifiers (Uglify) in the plugins array, or template literals may be transformed before minification.fixOrder plugins: minifyHTML first, then babel, then uglify.
affects: all
gotchaBy default, only tagged templates containing 'html' or 'css' (case insensitive) are minified. Untagged or differently tagged templates (e.g., Polymer) require custom shouldMinify option.fixProvide a shouldMinify function in options to match additional templates.
affects: all
deprecatedrollup-plugin-babel is deprecated; use @rollup/plugin-babel instead.fixReplace 'rollup-plugin-babel' with '@rollup/plugin-babel'.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-minify-html-literals'
Package not installed in node_modules.
fixRun 'npm install rollup-plugin-minify-html-literals --save-dev'
TypeError: (0 , _rollupPluginMinifyHtmlLiterals.default) is not a function
Using CommonJS require() instead of ES import.
fixUse 'import minifyHTML from "rollup-plugin-minify-html-literals"'
Error: rollup-plugin-minify-html-literals: Must be installed with rollup ^0.65.2 || ^1.0.0 || ^2.0.0
Incompatible Rollup version (e.g., Rollup 3 or 4).
fixDowngrade to Rollup 2.x or find an alternative plugin.
Audit
Dependencies
minify-html-literalsrequiredProvides the core minification logic for HTML/CSS template literals.
@rollup/pluginutilsrequiredUsed for filtering files with include/exclude patterns.
rolluprequiredPeer dependency; plugin requires Rollup as the bundler.