-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathvite.config.ts
More file actions
63 lines (58 loc) · 1.86 KB
/
vite.config.ts
File metadata and controls
63 lines (58 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import path from "path";
import { defineConfig, type ProxyOptions } from "vite";
import react from "@vitejs/plugin-react-swc";
import { tanstackRouter } from "@tanstack/router-plugin/vite";
import tailwindcss from "@tailwindcss/vite";
import { cloudflare } from "@cloudflare/vite-plugin";
const plugins = [
react(),
tailwindcss(),
tanstackRouter({
target: "react",
autoCodeSplitting: true,
}),
];
if (process.env.CLOUDFLARE_DEV === "true") {
plugins.push(cloudflare());
}
// Proxy configuration for mock server
const proxyConfig: Record<string, string | ProxyOptions> =
process.env.VITE_USE_MOCK === "true"
? {
"/v1": {
target: `http://localhost:${process.env.MOCK_PORT || 3001}`,
changeOrigin: true,
ws: true, // Enable WebSocket proxy for /v1/pty
},
}
: {};
// https://vite.dev/config/
export default defineConfig({
plugins,
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
server: {
host: "0.0.0.0", // Allow external connections
port: parseInt(process.env.VITE_PORT || "5173"),
strictPort: true, // Don't try other ports if configured port is busy
proxy: proxyConfig,
hmr: {
// Configure HMR for container development
host: "localhost",
port: parseInt(process.env.VITE_PORT || "5173"),
// path: process.env.CATNIP_DEV ? `/${process.env.VITE_PORT}` : undefined, // or whatever path your proxy uses for the socket
// Use WebSocket for HMR in containers
protocol: "ws",
},
watch: {
// Ignore .pnpm-store to prevent ENOSPC errors
ignored: ["**/node_modules/**", "**/.pnpm-store/**", "**/dist/**"],
},
},
clearScreen: false,
// Might need this for the proxy to work...
// base: process.env.CATNIP_DEV ? `/${process.env.VITE_PORT}` : undefined, // or whatever path your proxy uses for the socket
});