HTML minifier plugin for Vite
npm install -D vite-plugin-html-minifier
// vite.config.ts
import htmlMinifier from 'vite-plugin-html-minifier'
export default defineConfig({
plugins: [
htmlMinifier({
minify: true,
}),
],
})
Parameter | Type | Default | Description |
---|---|---|---|
minify | boolean|MinifyOptions |
true |
html minify option |
filter | RegExp|string|((fileName: string) => boolean) |
- | target file filter |
-
Type:
boolean | MinifyOptions
-
Default:
true
{ 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.
- Type:
RegExp | string | ((fileName: string) => boolean)
- Default: None (All entry point files will be matched)