Skip to content

Commit 6244ac9

Browse files
Rassilionlforst
andauthored
fix(vite): Fix environment variable loading issue for Windows (#545)
Co-authored-by: Luca Forstner <[email protected]>
1 parent 929451e commit 6244ac9

File tree

1 file changed

+5
-1
lines changed
  • packages/bundler-plugin-core/src

1 file changed

+5
-1
lines changed

Diff for: packages/bundler-plugin-core/src/index.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ export function sentryUnpluginFactory({
8585
);
8686
// NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want.
8787
const dotenvResult = dotenv.parse(dotenvFile);
88-
process.env = { ...process.env, ...dotenvResult };
88+
89+
// Vite has a bug/behaviour where spreading into process.env will cause it to crash
90+
// https://github.com/vitest-dev/vitest/issues/1870#issuecomment-1501140251
91+
Object.assign(process.env, dotenvResult);
92+
8993
logger.info('Using environment variables configured in ".env.sentry-build-plugin".');
9094
} catch (e: unknown) {
9195
// Ignore "file not found" errors but throw all others

0 commit comments

Comments
 (0)