import { fileURLToPath } from 'node:url'; import path from 'node:path'; import preact from '@preact/preset-vite'; import { defineConfig, type Plugin } from 'vite'; const rootDir = fileURLToPath(new URL('.', import.meta.url)); function searchIndexPolicyPlugin(isDemo: boolean): Plugin { return { name: 'nodewarden-search-index-policy', transformIndexHtml(html: string) { if (isDemo) return html; return html.replace( '', '\n ' ); }, generateBundle() { this.emitFile({ type: 'asset', fileName: 'robots.txt', source: isDemo ? 'User-agent: *\nAllow: /\n' : 'User-agent: *\nDisallow: /\n', }); }, }; } 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*