VibeGame / vite.config.ts
dylanebert
langgraph.js migration
ec75a88
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import { vibegame, consoleForwarding } from "vibegame/vite";
import { WebSocketServer } from "ws";
import { wsManager } from "./src/lib/server/api";
export default defineConfig({
plugins: [
svelte(),
vibegame(),
consoleForwarding(),
{
name: "websocket-server",
configureServer(server) {
const wss = new WebSocketServer({ noServer: true });
server.httpServer?.on("upgrade", (request, socket, head) => {
if (request.url === "/ws") {
wss.handleUpgrade(request, socket, head, (ws) => {
wsManager.handleConnection(ws, request);
});
}
});
server.middlewares.use((req, res, next) => {
if (req.url === "/auth/callback") {
res.statusCode = 200;
res.setHeader("Content-Type", "text/html");
res.end(`<!DOCTYPE html>
<html>
<head>
<title>Authenticating...</title>
<script type="module">
// Redirect to main app - the OAuth handler will process the URL params
window.location.href = '/';
</script>
</head>
<body>
<p>Authenticating...</p>
</body>
</html>`);
return;
}
next();
});
},
},
],
optimizeDeps: {
include: ["monaco-editor"],
},
server: {
host: "0.0.0.0",
port: parseInt(process.env.PORT || "7860"),
open: false,
strictPort: true,
allowedHosts: ["localhost", ".hf.space"],
},
build: {
target: "esnext",
sourcemap: true,
},
});