fix(vite): inline FRESH_PUBLIC_* env vars (#3221)
This commit is contained in:
@@ -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);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user