Adds react, react-dom, zustand, tailwindcss, @tailwindcss/vite as a new skeleton alongside the existing vanilla SPA. New src/index.tsx entry point (unused until wired into index.html in a later issue); main.ts stays the active entry.
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { defineConfig, loadEnv } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
|
|
// Where the dev proxy forwards `/api/*` (and the events WS) to. Default to a
|
|
// local daemon on 127.0.0.1:7070. Override with:
|
|
// MAESTRO_DAEMON_URL=http://laptop.lan:7070
|
|
// `ws://`/`wss://` forms are normalised to http/https, since the proxy needs an
|
|
// HTTP base URL.
|
|
function resolveProxyTarget(raw: string | undefined): string {
|
|
if (!raw) return "http://127.0.0.1:7070";
|
|
return raw
|
|
.replace(/^wss:\/\//, "https://")
|
|
.replace(/^ws:\/\//, "http://")
|
|
.replace(/\/+$/, "");
|
|
}
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
const target = resolveProxyTarget(env.MAESTRO_DAEMON_URL);
|
|
const secure = target.startsWith("https://");
|
|
return {
|
|
plugins: [react(), tailwindcss()],
|
|
build: {
|
|
target: "es2022",
|
|
outDir: "dist",
|
|
emptyOutDir: true,
|
|
sourcemap: false,
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
proxy: {
|
|
"/api": {
|
|
target,
|
|
changeOrigin: secure,
|
|
ws: true,
|
|
secure: false,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|