Registry / devops / vite-plugin-html-minifier

vite-plugin-html-minifier

JSON →
library1.0.5jsnpmunverified

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.

npm install vite-plugin-html-minifier
INSTALL
IMPORT
SIG · VITE-PLUGIN-HTML-M
V
vite-plugin-html-minifier
devopsjavascriptv1.0.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import htmlMinifier from 'vite-plugin-html-minifier'
import { htmlMinifier } from 'vite-plugin-html-minifier'
The package exports a default function; named import will fail.
htmlMinifier
const htmlMinifier = require('vite-plugin-html-minifier')
const { htmlMinifier } = require('vite-plugin-html-minifier')
CJS require returns the default export directly, not an object.
type
import type { MinifyOptions } from 'vite-plugin-html-minifier'
import { MinifyOptions } from 'vite-plugin-html-minifier'
MinifyOptions is a TypeScript type, not a runtime export. Use import type or import().

Shows basic usage of the plugin with custom minify options and filter regex.

// vite.config.ts import { defineConfig } from 'vite' import htmlMinifier from 'vite-plugin-html-minifier' export default defineConfig({ plugins: [ htmlMinifier({ minify: { collapseWhitespace: true, removeComments: true, minifyCSS: true, minifyJS: true }, filter: /.*\.html$/ }) ] })
Debug
Known issues
gotchaDefault import export expects default, not named.
fix
Use `import htmlMinifier from 'vite-plugin-html-minifier'` instead of named import.
affects: >=1.0.0
gotchaMinifyOptions is a type, not a value; cannot be imported using runtime import.
fix
Use `import type { MinifyOptions } from 'vite-plugin-html-minifier'`.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'vite-plugin-html-minifier' or its corresponding type declarations.
Package is not installed or TypeScript cannot locate types.
fix
Run `npm install -D vite-plugin-html-minifier` and ensure tsconfig.json includes 'node_modules/@types'.
TypeError: htmlMinifier is not a function
Using named import instead of default import in ESM.
fix
Change import to `import htmlMinifier from 'vite-plugin-html-minifier'`.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
viteoptionalpeer dependency, plugin only works with Vite >=3.0.0
Agent activity
6 hits · last 30 days
node
6
Resources
vite-plugin-html-minifier — npm install vite-plugin-html-minifier · libregistry