# vite-plugin-html-minifier

> HTML minifier plugin for Vite

Latest version **1.0.5** (published 2024-12-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-html-minifier
pnpm add vite-plugin-html-minifier
yarn add vite-plugin-html-minifier
bun add vite-plugin-html-minifier
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2024-12-05 |
| First published | 2022-08-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.10.0 |
| Dependencies | 1 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | erm1116 |
| Maintainers | erm1116 |
| Keywords | vite-plugin, html, minify |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-html-minifier
- Repository: https://github.com/erm1116/vite-plugin-html-minifier
- Issues: https://github.com/erm1116/vite-plugin-html-minifier/issues
- npm.io page: https://npm.io/package/vite-plugin-html-minifier

## Dependencies (1)

- [html-minifier-terser](https://npm.io/package/html-minifier-terser.md) ^7.2.0

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2024-12-05
- 1.0.4 — 2024-04-21
- 1.0.3 — 2023-02-11
- 1.0.2 — 2022-08-17
- 1.0.1 — 2022-08-16
- 1.0.0 — 2022-08-16

## README

# vite-plugin-html-minifier

HTML minifier plugin for Vite

## Usage

```sh
npm install -D vite-plugin-html-minifier
```

```ts
// vite.config.ts
import htmlMinifier from 'vite-plugin-html-minifier'

export default defineConfig({
  plugins: [
    htmlMinifier({
      minify: true,
    }),
  ],
})
```

## Options

| Parameter | Type                                               | Default | Description        |
| --------- | -------------------------------------------------- | ------- | ------------------ |
| minify    | `boolean｜MinifyOptions`                           | `true`  | html minify option |
| filter    | ` RegExp｜string｜((fileName: string) => boolean)` | -       | target file filter |

### `minify`

- Type: `boolean | MinifyOptions`
- Default: `true`

  ```js
  {
      collapseWhitespace: true,
      keepClosingSlash: true,
      removeComments: true,
      removeRedundantAttributes: true,
      removeScriptTypeAttributes: true,
      removeStyleLinkTypeAttributes: true,
      removeEmptyAttributes: true,
      useShortDoctype: true,
      minifyCSS: true,
      minifyJS: true,
      minifyURLs: true,
  }
  ```

  `MinifierOptions` is same as [html-minifier-terser options](https://github.com/terser/html-minifier-terser#options-quick-reference).

### `filter`

- Type: `RegExp | string | ((fileName: string) => boolean)`
- Default: None (All entry point files will be matched)

---
_Source: https://npm.io/package/vite-plugin-html-minifier · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
