-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
46 lines (41 loc) · 1.17 KB
/
vite.config.ts
File metadata and controls
46 lines (41 loc) · 1.17 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
import { fileURLToPath, URL } from "node:url";
import { cloudflare } from "@cloudflare/vite-plugin";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import react from "@vitejs/plugin-react";
import { defineConfig, loadEnv } from "vite";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const allowedHosts = new Set<string>();
const appUrl = env.APP_URL?.trim();
if (appUrl) {
try {
allowedHosts.add(new URL(appUrl).hostname);
} catch {
// Ignore invalid APP_URL values here; runtime config will fail separately.
}
}
const extraAllowedHosts = env.VITE_ALLOWED_HOSTS?.split(",")
.map((host) => host.trim())
.filter(Boolean);
for (const host of extraAllowedHosts ?? []) {
allowedHosts.add(host);
}
return {
resolve: {
alias: {
"~": fileURLToPath(new URL("./src", import.meta.url)),
},
},
plugins: [
tanstackStart(),
react(),
cloudflare({
viteEnvironment: { name: "ssr" },
auxiliaryWorkers: [{ configPath: "./wrangler.aux.jsonc" }],
}),
],
server: {
allowedHosts: [...allowedHosts],
},
};
});