diff --git a/webapp/vite.config.ts b/webapp/vite.config.ts index 7f18fc5..930afcf 100644 --- a/webapp/vite.config.ts +++ b/webapp/vite.config.ts @@ -1,11 +1,11 @@ import { fileURLToPath } from 'node:url'; import path from 'node:path'; import preact from '@preact/preset-vite'; -import { defineConfig } from 'vite'; +import { defineConfig, type Plugin } from 'vite'; const rootDir = fileURLToPath(new URL('.', import.meta.url)); -function searchIndexPolicyPlugin(isDemo: boolean) { +function searchIndexPolicyPlugin(isDemo: boolean): Plugin { return { name: 'nodewarden-search-index-policy', transformIndexHtml(html: string) { @@ -27,12 +27,39 @@ function searchIndexPolicyPlugin(isDemo: boolean) { }; } +function resourcePriorityPlugin(isDemo: boolean): Plugin { + return { + name: 'nodewarden-resource-priority', + enforce: 'post' as const, + transformIndexHtml(html: string) { + if (isDemo || !html.includes('/assets/app-suite-')) return html; + + const scriptMatch = html.match(/^\s*