diff options
author | 2022-12-09 23:49:07 +0100 | |
---|---|---|
committer | 2022-12-11 12:18:43 +0100 | |
commit | 280a3fab74348697429b7bab56b3436968113d79 (patch) | |
tree | e1603153db18f7f35c1bcceb03462409f75002db /subprojects/frontend/config/minifyHTMLVitePlugin.ts | |
parent | refactor(frontend): lazy load XtextClient (diff) | |
download | refinery-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.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 | } | ||