Files
Simon James b54a3139c7 Initial commit: Qortal Web Builder monorepo.
Includes QWB, Qortal Web, and Q-Shops Q-Apps with shared packages and build scripts.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 12:17:29 +00:00

38 lines
1016 B
TypeScript

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 = /<script[^>]*\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('</body>', ` ${tag}\n </body>`);
}
return h;
},
},
};
}
export default defineConfig({
plugins: [react(), qAppHtmlPost()],
base: './',
build: {
outDir: 'dist',
assetsDir: 'assets',
sourcemap: false,
},
});