You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In 2.9, running vite command using an alternative root has vite looking for .env files in the alternative root directory.
The provide example can be fixed by adding a vite config file using this config : envDir: ../
I don't know if this is intended. Prior to 2.9, specifying an alternative root required specifying the vite.config file path if it was not located in the alternative folder, but didn't change the envDir default path. It now does and breaks projects using environment files not located in the alternative root folder.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
Introduced in #6995. The docs initially mentioned that envDir defaults to the root, so if you change the root, it should load env files in that root directory only. So I don't think it's a breaking change.
The way I see it is that this is a "breaking bug fix". Meaning that some projects may have been relying on the 2.8 behavior, event though it was the wrong one (I encountered the issue using .env file at the root project of a monorepo for instance).
Maybe a warning in the 2.9 release not could be enough
Describe the bug
In 2.9, running vite command using an alternative root has vite looking for .env files in the alternative root directory.
The provide example can be fixed by adding a vite config file using this config :
envDir: ../
I don't know if this is intended. Prior to 2.9, specifying an alternative root required specifying the vite.config file path if it was not located in the alternative folder, but didn't change the envDir default path. It now does and breaks projects using environment files not located in the alternative root folder.
Reproduction
https://stackblitz.com/edit/vitejs-vite-yvysne?file=package.json
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: