Registry / web-framework / rollup-plugin-minify-html-literals

rollup-plugin-minify-html-literals

JSON →
library1.2.6jsnpmunverified

Rollup plugin that minifies HTML and CSS content inside JavaScript template literal strings. Version 1.2.6 is current and stable. It leverages the minify-html-literals library to process tagged templates (e.g., lit-html) and untagged templates (e.g., Polymer). Key differentiators: seamless Rollup integration, support for include/exclude patterns, fail-on-error mode, and the ability to customize the minification logic. Typical use cases: reducing bundle size for Web Component projects using lit-html or Polymer.

npm install rollup-plugin-minify-html-literals
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-MINI
R
rollup-plugin-minify-html-literals
web-frameworkjavascriptv1.2.6
harness data pending
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.
fix
Use 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.
fix
Order 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.
fix
Provide a shouldMinify function in options to match additional templates.
affects: all
deprecatedrollup-plugin-babel is deprecated; use @rollup/plugin-babel instead.
fix
Replace '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.
fix
Run 'npm install rollup-plugin-minify-html-literals --save-dev'
TypeError: (0 , _rollupPluginMinifyHtmlLiterals.default) is not a function
Using CommonJS require() instead of ES import.
fix
Use '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).
fix
Downgrade to Rollup 2.x or find an alternative plugin.
Upgrade
Version history
1.2.6latest on npm
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.
Agent activity
2 hits · last 30 days
node
2
Resources
rollup-plugin-minify-html-literals — npm install rollup-plugin-minify-html-literals · libregistry