{"id":27357,"library":"rollup-plugin-minify-html-literals","title":"rollup-plugin-minify-html-literals","description":"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.","status":"active","version":"1.2.6","language":"javascript","source_language":"en","source_url":"https://github.com/asyncLiz/rollup-plugin-minify-html-literals","tags":["javascript","rollup-plugin","minify","html","literal","literals","template","tagged","lit-html","typescript"],"install":[{"cmd":"npm install rollup-plugin-minify-html-literals","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-minify-html-literals","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-minify-html-literals","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the core minification logic for HTML/CSS template literals.","package":"minify-html-literals","optional":false},{"reason":"Used for filtering files with include/exclude patterns.","package":"@rollup/pluginutils","optional":false},{"reason":"Peer dependency; plugin requires Rollup as the bundler.","package":"rollup","optional":false}],"imports":[{"note":"ESM-only package; CommonJS require() fails. Use dynamic import() if needed.","wrong":"const minifyHTML = require('rollup-plugin-minify-html-literals')","symbol":"default","correct":"import minifyHTML from 'rollup-plugin-minify-html-literals'"},{"note":"The package exports a single function as default; named import will be undefined.","wrong":"import { minifyHTML } from 'rollup-plugin-minify-html-literals'","symbol":"default","correct":"const minifyHTML = require('rollup-plugin-minify-html-literals')"},{"note":"TypeScript types are shipped; you can import types for Options.","wrong":null,"symbol":"type definitions","correct":"import type { Options } from 'rollup-plugin-minify-html-literals'"}],"quickstart":{"code":"import minifyHTML from 'rollup-plugin-minify-html-literals';\n\nexport default {\n  input: 'src/index.js',\n  output: { file: 'dist/bundle.js', format: 'iife' },\n  plugins: [\n    minifyHTML({\n      include: 'src/**/*.js',\n      options: {\n        shouldMinify: (template) => {\n          return template.parts.some(p => p.text.includes('<style') || p.text.includes('<dom-module'));\n        }\n      }\n    })\n  ]\n};","lang":"javascript","description":"Rollup configuration demonstrating how to use the plugin with include option and custom shouldMinify for Polymer templates."},"warnings":[{"fix":"Use Rollup 2 or lower, or switch to an alternative like @rollup/plugin-minify-html-literals.","message":"Rollup 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.","severity":"breaking","affected_versions":"<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')"},{"fix":"Order plugins: minifyHTML first, then babel, then uglify.","message":"The plugin must be placed before transpilers (Babel) and other minifiers (Uglify) in the plugins array, or template literals may be transformed before minification.","severity":"gotcha","affected_versions":"all"},{"fix":"Provide a shouldMinify function in options to match additional templates.","message":"By default, only tagged templates containing 'html' or 'css' (case insensitive) are minified. Untagged or differently tagged templates (e.g., Polymer) require custom shouldMinify option.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace 'rollup-plugin-babel' with '@rollup/plugin-babel'.","message":"rollup-plugin-babel is deprecated; use @rollup/plugin-babel instead.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'npm install rollup-plugin-minify-html-literals --save-dev'","cause":"Package not installed in node_modules.","error":"Error: Cannot find module 'rollup-plugin-minify-html-literals'"},{"fix":"Use 'import minifyHTML from \"rollup-plugin-minify-html-literals\"'","cause":"Using CommonJS require() instead of ES import.","error":"TypeError: (0 , _rollupPluginMinifyHtmlLiterals.default) is not a function"},{"fix":"Downgrade to Rollup 2.x or find an alternative plugin.","cause":"Incompatible Rollup version (e.g., Rollup 3 or 4).","error":"Error: rollup-plugin-minify-html-literals: Must be installed with rollup ^0.65.2 || ^1.0.0 || ^2.0.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}