Fix Vercel build by avoiding Supabase init during Vite config load and harden server Supabase init

cgen-ff07f5499dbd4adf8a80568e8899d8c2
This commit is contained in:
Builder.io 2025-09-30 00:13:23 +00:00
parent 3d3b12aa7f
commit c3ac16c346

View file

@ -1,7 +1,6 @@
import { defineConfig, Plugin } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { createServer } from "./server";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
@ -30,10 +29,13 @@ function expressPlugin(): Plugin {
name: "express-plugin",
apply: "serve", // Only apply during development (serve mode)
configureServer(server) {
const app = createServer();
// Add Express app as middleware to Vite dev server
server.middlewares.use(app);
(async () => {
const { createServer } = await import("./server");
const app = createServer();
server.middlewares.use(app);
})().catch((e) => {
console.error("Failed to start express middleware:", e);
});
},
};
}