Skip to content

Commit

Permalink
fix: respect user env if provided
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Feb 9, 2022
1 parent f30c3ca commit 38a8deb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/vitest/src/node/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest())
options = deepMerge(options, viteConfig.test as any || {})
options.api = resolveApiConfig(options)

process.env.BASE_URL = viteConfig.base
process.env.MODE = viteConfig.mode
process.env.BASE_URL ??= viteConfig.base
process.env.MODE ??= viteConfig.mode
// process.env can have only string values and will cast string on it if we pass other type,
// so we are making them truthy
process.env.PROD = viteConfig.env.PROD ? '1' : ''
process.env.DEV = viteConfig.env.DEV ? '1' : ''
process.env.SSR = '1'
process.env.PROD ??= viteConfig.env.PROD ? '1' : ''
process.env.DEV ??= viteConfig.env.DEV ? '1' : ''
process.env.SSR ??= '1'

// account for user env defines
for (const key in viteConfig.define) {
Expand Down

0 comments on commit 38a8deb

Please sign in to comment.