diff options
Diffstat (limited to 'subprojects/frontend/config/minifyHTMLVitePlugin.ts')
-rw-r--r-- | subprojects/frontend/config/minifyHTMLVitePlugin.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/subprojects/frontend/config/minifyHTMLVitePlugin.ts b/subprojects/frontend/config/minifyHTMLVitePlugin.ts new file mode 100644 index 00000000..18336d4d --- /dev/null +++ b/subprojects/frontend/config/minifyHTMLVitePlugin.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { minify, type Options as TerserOptions } from 'html-minifier-terser'; | ||
2 | import type { PluginOption } from 'vite'; | ||
3 | |||
4 | export default function minifyHTMLVitePlugin( | ||
5 | options?: TerserOptions | undefined, | ||
6 | ): PluginOption { | ||
7 | return { | ||
8 | name: 'minify-html', | ||
9 | apply: 'build', | ||
10 | enforce: 'post', | ||
11 | transformIndexHtml(html) { | ||
12 | return minify(html, { | ||
13 | collapseWhitespace: true, | ||
14 | collapseBooleanAttributes: true, | ||
15 | minifyCSS: true, | ||
16 | removeComments: true, | ||
17 | removeAttributeQuotes: true, | ||
18 | removeRedundantAttributes: true, | ||
19 | sortAttributes: true, | ||
20 | ...(options ?? {}), | ||
21 | }); | ||
22 | }, | ||
23 | }; | ||
24 | } | ||