{"id":22059,"library":"rollup-plugin-html-minifier","title":"rollup-plugin-html-minifier","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/juliendargelos/rollup-plugin-html-minifier","tags":["javascript","typescript"],"install":[{"cmd":"npm install rollup-plugin-html-minifier","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-html-minifier","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-html-minifier","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for plugin functionality","package":"rollup","optional":false}],"imports":[{"note":"Default export; ESM-only. CommonJS require will fail in Node.js without ESM support.","wrong":"const htmlMinifier = require('rollup-plugin-html-minifier')","symbol":"htmlMinifier","correct":"import htmlMinifier from 'rollup-plugin-html-minifier'"},{"note":"TypeScript type export, not a value.","wrong":"import { PluginOptions } from 'rollup-plugin-html-minifier' (if used as value)","symbol":"PluginOptions","correct":"import type { PluginOptions } from 'rollup-plugin-html-minifier'"},{"note":"Passing an empty options object results in no minification; html-minifier options must be explicitly enabled.","wrong":"htmlMinifier() without options (no minification occurs as defaults are mostly disabled)","symbol":"htmlMinifier (with options object)","correct":"import htmlMinifier from 'rollup-plugin-html-minifier'; htmlMinifier({ include: '*.html', options: { removeComments: true } })"}],"quickstart":{"code":"// rollup.config.js\nimport htmlMinifier from 'rollup-plugin-html-minifier';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'esm',\n  },\n  plugins: [\n    htmlMinifier({\n      include: '*.html',\n      options: {\n        removeComments: true,\n        collapseWhitespace: true,\n        removeAttributeQuotes: true,\n        minifyJS: true,\n        minifyCSS: true,\n      },\n    }),\n  ],\n};","lang":"typescript","description":"Minifies all HTML files matched by the glob pattern, enabling several html-minifier options for effective compression."},"warnings":[{"fix":"Upgrade Rollup to version 2.10.0 or later.","message":"Version 2.0.0 requires Rollup >= 2.10.0; older Rollup versions will break.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Set desired options explicitly, e.g., options.collapseWhitespace: true.","message":"Most html-minifier options are disabled by default; passing an empty options object yields no minification.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure HTML files are part of the Rollup bundle (e.g., through @rollup/plugin-html or a manual emit).","message":"The plugin does not process files that are not emitted or transformed by Rollup; include/exclude patterns only filter within Rollup's asset pipeline.","severity":"gotcha","affected_versions":">=0.0.0"}],"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-html-minifier --save-dev","cause":"Package not installed or missing from node_modules.","error":"Error: Could not resolve 'rollup-plugin-html-minifier'"},{"fix":"Use import syntax or configure Node.js to handle ESM (e.g., type: 'module' in package.json).","cause":"Using CommonJS require() on a package that exports ESM only.","error":"TypeError: htmlMinifier is not a function"},{"fix":"Ensure the HTML file is included in Rollup's bundle and pass explicit options like { removeComments: true }.","cause":"html-minifier options are all disabled; no minification applied, but content may also be missing if the plugin didn't process the file.","error":"The emitted file 'index.html' is empty after build"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}