vite
vite copied to clipboard
Breaking change to env vars expansion since [email protected]
Describe the bug
We're using env expansion feature for our .env files.
Given following .env file as example:
# .env
VITE_SOURCE=12345
VITE_EXPANDED=$VITE_SOURCE-678-ab
We expect, the behaviour of Vite@<=5.1.1:
console.log(import.meta.env.VITE_EXPANDED) // 12345-678-ab
Actual result for Vite@>=5.1.2:
console.log(import.meta.env.VITE_EXPANDED) // 12345
the -678-ab part is missing now
Reproduction
https://stackblitz.com/edit/vitejs-vite-yalk8f?file=.env
Steps to reproduce
- have any setup with [email protected]+
- have any .env file setup
- in .env file have an env variable vith env expansion and trailing content
UPD: Seems that the braking change have only affected the env expansion with kebab-cased content after the env var reference.
Example:
Vite@<=5.1.1 (correct)
Vite@>=5.1.2 (breaking change)
You can try it yourself by changing a Vite version in this minimalistic Vite-only example
System Info
Seems to be reproducible in setup and package manager.
Verified on:
Package managers: npm, pnpm
Envs: OS X, StackBlitz
Vite setup: `npm create vite` is just fine
.env loading method: both
- .env in root directory with zero configuration
- via `loadEnv()`
Used Package Manager
npm
Logs
No response
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] 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 vuejs/core instead.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
The root cause seems to be dotenv-expand@^11.0.3, brought to [email protected] with #15875
See the issue motdotla/dotenv-expand#124
Working on this issue
having the same issue. thanks @akashMasih for working on a solution!
Hey @akashMasih @bitbirddev, don't hesitate to collaborate on root-cause issue motdotla/dotenv-expand#124 as well. Just a thumbs up or a comment would be great :wink: