fix(vite): inline FRESH_PUBLIC_* env vars (#3221)

This commit is contained in:
Marvin Hagemeister
2025-08-16 23:14:03 +02:00
committed by GitHub
parent 59549c9532
commit f80d049dca
7 changed files with 203 additions and 7 deletions
+11 -1
View File
@@ -50,6 +50,7 @@ async function copyDir(from: string, to: string) {
export async function withDevServer(
fixtureDir: string,
fn: (address: string, dir: string) => void | Promise<void>,
env: Record<string, string> = {},
) {
await using tmp = await withTmpDir({
dir: path.join(import.meta.dirname!, ".."),
@@ -72,7 +73,7 @@ export default defineConfig({
);
await withChildProcessServer(
{ cwd: tmp.dir, args: ["run", "-A", "npm:vite", "--port", "0"] },
{ cwd: tmp.dir, args: ["run", "-A", "npm:vite", "--port", "0"], env },
async (address) => await fn(address, tmp.dir),
);
}
@@ -110,3 +111,12 @@ export async function buildVite(fixtureDir: string) {
},
};
}
export function usingEnv(name: string, value: string) {
Deno.env.set(name, value);
return {
[Symbol.dispose]: () => {
Deno.env.delete(name);
},
};
}