- Move all application env vars to repository-root .env (with .env.example as the committed template) and drop the per-app .env.example files. - Add @code/env subpaths (agent, convex) and consume validated exports everywhere instead of reading process.env directly. - Wire every dev/build/start script to load ../../.env via bun --env-file and point vite.config.ts envDir at the repo root.
18 lines
541 B
TypeScript
18 lines
541 B
TypeScript
import { createEnv } from "@t3-oss/env-core";
|
|
import { z } from "zod";
|
|
|
|
const convexUrlSchema = (exampleHost: string) =>
|
|
z.url().refine((url) => new URL(url).hostname !== exampleHost, {
|
|
message: `Replace the ${exampleHost} placeholder before running the app`,
|
|
});
|
|
|
|
export const env = createEnv({
|
|
client: {
|
|
VITE_CONVEX_SITE_URL: convexUrlSchema("example.convex.site"),
|
|
VITE_CONVEX_URL: convexUrlSchema("example.convex.cloud"),
|
|
},
|
|
clientPrefix: "VITE_",
|
|
emptyStringAsUndefined: true,
|
|
runtimeEnv: import.meta.env,
|
|
});
|