{"id":22691,"library":"vite-plugin-html-minifier","title":"vite-plugin-html-minifier","description":"A Vite plugin that minifies HTML output using html-minifier-terser. Current stable version 1.0.5, released 2024-12. Compatible with Vite >=3.0.0. Differentiators: simple configuration, supports both boolean and fine-grained MinifyOptions, allows filtering via regex/string/function. Ships TypeScript types. Requires Node >=20.10.0 and pnpm >=9.0.4 as recommended by the package.","status":"active","version":"1.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/erm1116/vite-plugin-html-minifier","tags":["javascript","vite-plugin","html","minify","typescript"],"install":[{"cmd":"npm install vite-plugin-html-minifier","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-html-minifier","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-html-minifier","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, plugin only works with Vite >=3.0.0","package":"vite","optional":true}],"imports":[{"note":"The package exports a default function; named import will fail.","wrong":"import { htmlMinifier } from 'vite-plugin-html-minifier'","symbol":"default","correct":"import htmlMinifier from 'vite-plugin-html-minifier'"},{"note":"CJS require returns the default export directly, not an object.","wrong":"const { htmlMinifier } = require('vite-plugin-html-minifier')","symbol":"htmlMinifier","correct":"const htmlMinifier = require('vite-plugin-html-minifier')"},{"note":"MinifyOptions is a TypeScript type, not a runtime export. Use import type or import().","wrong":"import { MinifyOptions } from 'vite-plugin-html-minifier'","symbol":"type","correct":"import type { MinifyOptions } from 'vite-plugin-html-minifier'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite'\nimport htmlMinifier from 'vite-plugin-html-minifier'\n\nexport default defineConfig({\n  plugins: [\n    htmlMinifier({\n      minify: {\n        collapseWhitespace: true,\n        removeComments: true,\n        minifyCSS: true,\n        minifyJS: true\n      },\n      filter: /.*\\.html$/\n    })\n  ]\n})","lang":"typescript","description":"Shows basic usage of the plugin with custom minify options and filter regex."},"warnings":[{"fix":"Use `import htmlMinifier from 'vite-plugin-html-minifier'` instead of named import.","message":"Default import export expects default, not named.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `import type { MinifyOptions } from 'vite-plugin-html-minifier'`.","message":"MinifyOptions is a type, not a value; cannot be imported using runtime import.","severity":"gotcha","affected_versions":">=1.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 -D vite-plugin-html-minifier` and ensure tsconfig.json includes 'node_modules/@types'.","cause":"Package is not installed or TypeScript cannot locate types.","error":"Cannot find module 'vite-plugin-html-minifier' or its corresponding type declarations."},{"fix":"Change import to `import htmlMinifier from 'vite-plugin-html-minifier'`.","cause":"Using named import instead of default import in ESM.","error":"TypeError: htmlMinifier is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}