Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
48 lines (46 loc) · 1.92 KB
/
Copy pathvite.config.ts
File metadata and controls
48 lines (46 loc) · 1.92 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
// @lovable.dev/vite-tanstack-config already includes the following — do NOT add them manually
// or the app will break with duplicate plugins:
// - TanStack devtools (dev-only, first), tanstackStart, viteReact, tailwindcss, tsConfigPaths,
// nitro (build-only using cloudflare as a default target), VITE_* env injection, @ path alias,
// React/TanStack dedupe, error logger plugins, and sandbox detection (port/host/strictPort).
// You can pass additional config via defineConfig({ vite: { ... }, etc... }) if needed.
import path from "node:path";
import { loadEnv } from "vite";
import { defineConfig } from "@lovable.dev/vite-tanstack-config";
import { mcpPlugin } from "@lovable.dev/mcp-js/stacks/tanstack/vite";
// Server-side env vars (no VITE_ prefix) must be available to server routes.
// These are NOT injected into the client bundle.
const serverEnv = loadEnv(process.env["NODE_ENV"] ?? "development", process.cwd(), "");
Object.assign(process.env, serverEnv);
export default defineConfig({
// The public MCP surface at /mcp is project-authored (anonymous handshake +
// read-only tools, OAuth for writes), so the codegen emits its own
// OAuth-protected route elsewhere and leaves our routes alone.
plugins: [
mcpPlugin({
path: "/api/mcp-oauth",
restRoutes: false,
protectedResourceMetadataRoute: false,
}),
],
tanstackStart: {
// Redirect TanStack Start's bundled server entry to src/server.ts (our SSR error wrapper).
// nitro/vite builds from this
server: { entry: "server" },
},
vite: {
resolve: {
alias: {
"entities/lib/decode.js": path.resolve(
process.cwd(),
"node_modules/entities/lib/decode.js",
),
"entities/lib/encode.js": path.resolve(
process.cwd(),
"node_modules/entities/lib/encode.js",
),
entities: path.resolve(process.cwd(), "node_modules/entities"),
},
},
},
});