import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { defineConfig, type Plugin } from 'vite'; import react from '@vitejs/plugin-react'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** Strip crossorigin from built tags — same rationale as Qortal Web Builder Hub loads. */ function qAppHtmlPost(): Plugin { return { name: 'qapp-html', transformIndexHtml: { order: 'post', handler(html) { let h = html.replace(/\s+crossorigin(?:=[^\s>]*)?/gi, ''); const re = /]*\btype="module"[^>]*\bsrc="[^"]+"[^>]*>\s*<\/script>\s*/i; const m = h.match(re); if (m) { const tag = m[0].trim(); h = h.replace(re, ''); h = h.replace('', ` ${tag}\n `); } return h; }, }, }; } export default defineConfig({ plugins: [react(), qAppHtmlPost()], base: './', build: { outDir: 'dist', assetsDir: 'assets', sourcemap: false, }, });