TLDR:
When running Fresh via Vite, the .env file is not properly loaded into the process.
Reproduction:
// .env file
CUSTOM="debug_value"
// vite.config.ts (to error out as soon as possible after reproduction)
console.log(`CUSTOM env var from dotenvfile: ${Deno.env.get("CUSTOM")}`);
process.exit(1)
Running vite dev task:
deno task dev
Task dev vite
CUSTOM env var from dotenvfile: undefined
Additional Info
When running the file manually using deno run -A --env vite.config.ts
it works:
deno run -A --env vite.config.ts
CUSTOM env var from dotenvfile: debug_value
Assumption
This may be totally wrong, but I assume that vite runs the deno subcommand by using deno run -A FILE but is missing --env --> deno run -A --env FILE
Because adding
// in vite.config.ts
import "jsr:@std/dotenv/load";
to the file also works when using deno run -A FILE (by omitting --env)
deno run -A vite.config.ts
CUSTOM env var from dotenvfile: debug_value
TLDR:
When running Fresh via Vite, the .env file is not properly loaded into the process.
Reproduction:
Running vite dev task:
Additional Info
When running the file manually using
deno run -A --env vite.config.tsit works:
Assumption
This may be totally wrong, but I assume that vite runs the
denosubcommand by usingdeno run -A FILEbut is missing--env-->deno run -A --env FILEBecause adding
to the file also works when using
deno run -A FILE(by omitting --env)