forked from every-app/open-seo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
78 lines (76 loc) · 2.46 KB
/
Copy pathvite.config.ts
File metadata and controls
78 lines (76 loc) · 2.46 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { fileURLToPath } from "node:url";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import { defineConfig, loadEnv } from "vite";
import tsConfigPaths from "vite-tsconfig-paths";
import viteReact from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import { cloudflare } from "@cloudflare/vite-plugin";
import { devtools } from "@tanstack/devtools-vite";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const port = process.env.PORT
? Number(process.env.PORT)
: env.PORT
? Number(env.PORT)
: 3001;
const showDevtools = env.VITE_SHOW_DEVTOOLS !== "false";
const allowedHosts = [
env.ALLOWED_HOST,
env.BETTER_AUTH_URL ? new URL(env.BETTER_AUTH_URL).hostname : undefined,
].filter((host): host is string => Boolean(host));
const emitSourcemaps = env.POSTHOG_SOURCEMAPS === "true";
return {
resolve: {
alias: {
// TODO: Remove this workaround once @cloudflare/think stops eagerly
// importing just-bash at module init
// (https://github.com/cloudflare/agents/issues/1673).
//
// just-bash (plus its turndown → @mixmark-io/domino chain, ~30 MB of
// source) is only used by Think's workspace bash tool, which SAM
// disables — but the eager import drags it into the main worker's
// startup module graph, inflating every isolate's baseline heap
// toward the 128 MB limit (production OOM bursts on unrelated
// routes). Alias it to a throwing stub so it never ships.
"just-bash": fileURLToPath(
new URL("./src/server/lib/just-bash-stub.ts", import.meta.url),
),
},
},
envPrefix: [
"VITE_",
"AUTH_MODE",
"BYPASS_EMAIL_VERIFICATION",
"POSTHOG_PUBLIC_KEY",
"POSTHOG_HOST",
"TURNSTILE_SITE_KEY",
],
server: {
allowedHosts,
port,
},
preview: {
allowedHosts,
port,
},
build: {
sourcemap: emitSourcemaps,
outDir: emitSourcemaps ? "dist-sourcemaps" : "dist",
},
plugins: [
showDevtools
? devtools({
consolePiping: {
enabled: true,
levels: ["log", "warn", "error", "info", "debug"],
},
})
: null,
cloudflare({ inspectorPort: false, viteEnvironment: { name: "ssr" } }),
tsConfigPaths(),
tanstackStart(),
viteReact(),
tailwindcss(),
],
};
});