aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/config/minifyHTMLVitePlugin.ts
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-12-09 23:49:07 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-12-11 12:18:43 +0100
commit280a3fab74348697429b7bab56b3436968113d79 (patch)
treee1603153db18f7f35c1bcceb03462409f75002db /subprojects/frontend/config/minifyHTMLVitePlugin.ts
parentrefactor(frontend): lazy load XtextClient (diff)
downloadrefinery-280a3fab74348697429b7bab56b3436968113d79.tar.gz
refinery-280a3fab74348697429b7bab56b3436968113d79.tar.zst
refinery-280a3fab74348697429b7bab56b3436968113d79.zip
refactor(frontend): split vite config
Also introduces tsconfig.shared.json to keep track of source files used both and build time and in the browser.
Diffstat (limited to 'subprojects/frontend/config/minifyHTMLVitePlugin.ts')
-rw-r--r--subprojects/frontend/config/minifyHTMLVitePlugin.ts24
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 @@
1import { minify, type Options as TerserOptions } from 'html-minifier-terser';
2import type { PluginOption } from 'vite';
3
4export 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}