import { defineConfig } from 'vite'; import { minify } from 'html-minifier-terser'; const htmlMinifyOptions = { collapseBooleanAttributes: true, collapseInlineTagWhitespace: true, collapseWhitespace: true, conservativeCollapse: true, decodeEntities: true, minifyCSS: true, minifyJS: true, processConditionalComments: true, removeComments: true, removeEmptyAttributes: true, removeOptionalTags: true, removeRedundantAttributes: true, sortAttributes: true, sortClassName: true, useShortDoctype: true, }; export default defineConfig({ plugins: [ { name: 'minify-html', apply: 'build', enforce: 'post', transformIndexHtml: { order: 'post', handler(html) { return minify(html, htmlMinifyOptions); }, }, }, ], });