Created
March 22, 2023 23:23
-
-
Save malobre/4eb3e281fc9dc05d4c79bb59d59c87eb to your computer and use it in GitHub Desktop.
`html-minifier` as a vite plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { minify as minifyHTML } from "html-minifier"; | |
const vitePluginHtmlMinifier = { | |
name: "html-minifier", | |
apply: "build", | |
transformIndexHtml: (html) => minifyHTML(html, { | |
collapseWhitespace: true, | |
collapseInlineTagWhitespace: true, | |
collapseBooleanAttributes: true, | |
decodeEntities: true, | |
includeAutoGeneratedTags: false, | |
minifyCSS: true, | |
minifyJS: true, | |
removeAttributeQuotes: true, | |
removeComments: true, | |
removeOptionalTags: true, | |
removeScriptTypeAttributes: true, | |
removeStyleLinkTypeAttributes: true, | |
}), | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment