36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
import { defineConfig } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
export default defineConfig(({ command }) => {
|
|
if (command !== "serve" || !process.env.LOCAL_DEV_SESSION_TOKEN) throw new Error("Use scripts/local-dev.ts; this config cannot build production assets");
|
|
const root = path.dirname(fileURLToPath(import.meta.url));
|
|
const sso = path.join(root, "src/lib/sso");
|
|
return {
|
|
// Vite 5 requires a path, not `false`. No .env file can exist below /dev/null.
|
|
root, envDir: "/dev/null",
|
|
define: {
|
|
"import.meta.env.VITE_LOCAL_SESSION_TOKEN": JSON.stringify(process.env.LOCAL_DEV_SESSION_TOKEN),
|
|
// Keep requests on the local proxy, without the dev-only queue fixtures.
|
|
"import.meta.env.VITE_DEBUG": JSON.stringify("1"),
|
|
"import.meta.env.DEV": "false",
|
|
},
|
|
plugins: [react(), {
|
|
name: "local-only-sso", enforce: "pre",
|
|
resolveId(source, importer) {
|
|
if (!importer || !source.startsWith(".")) return;
|
|
const resolved = path.resolve(path.dirname(importer), source).replace(/\.ts$/, "");
|
|
if (resolved === sso) return path.resolve(root, "../scripts/local-sso.ts");
|
|
},
|
|
}],
|
|
server: {
|
|
host: "127.0.0.1", port: 63868, strictPort: true,
|
|
proxy: {
|
|
"/api": { target: "http://127.0.0.1:63869", changeOrigin: true },
|
|
"/ws": { target: "ws://127.0.0.1:63869", changeOrigin: true, ws: true },
|
|
},
|
|
},
|
|
};
|
|
});
|