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

55 lines
1.7 KiB
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));
const repoRoot = path.resolve(__dirname, '..');
const qwbCore = path.resolve(repoRoot, 'src');
const qwbVisitor = path.resolve(repoRoot, 'packages/qwb-visitor/src');
const builderStoreShim = path.resolve(qwbVisitor, 'store/builderStoreShim.ts');
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: './',
resolve: {
alias: {
'@qwb/core': qwbCore,
'@qwb/visitor': qwbVisitor,
'@qwb/styles': path.resolve(repoRoot, 'style.css'),
[path.resolve(qwbCore, 'store/builderStore.ts')]: builderStoreShim,
[path.resolve(qwbCore, 'lib/qortalEnv.ts')]: path.resolve(__dirname, 'src/lib/qortalEnvShim.ts'),
[path.resolve(qwbCore, 'lib/qortalClient.ts')]: path.resolve(__dirname, 'src/lib/qortalClientShim.ts'),
},
dedupe: ['react', 'react-dom', 'zustand'],
},
build: {
outDir: 'dist',
assetsDir: 'assets',
sourcemap: false,
},
optimizeDeps: {
include: ['react', 'react-dom', 'zustand'],
},
});