-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vite fatal error when a variable in .env ends with "$", even if it is not accessible by Vite. #12006
Comments
This is intentional to how dotenv-expand works. It thinks that the $ is a variable that it tries to expand, however it can't so it reports the error. You can fix it with:
|
Hi, Vite documentation also states that "[..] Only VITE_SOME_KEY will be exposed as import.meta.env.VITE_SOME_KEY to your client source code, [..]". Basically .env file (as single source for project configuration) may contain variables that are completely outside of scope for Vite/javascript source code. Therefore escaping them might not be possible or would require changes in unrelated code (e.g. Symfony framework, as OP suggested.). Wouldn't it be possible to enfore dotenv-expand only on VITE_* variables? |
After discussion with @patak-dev, we think it might be worth skipping for private variables. That would mean patching dotenv-expand, but it should be possible. |
Skipping for private variables will cause an error when
To avoid impacting irrelevant private variables, I think patching |
Describe the bug
I have a project where a single .env file is used by both vite and symfony (PHP). There is a variable for symfony that ends with "$".
Might be a regression of this: #6858
Expectation:
npm install && npm run dev
runs successfully - starts devserverReality:
npm install && npm run dev
fails with the following output:Reproduction
https://github.com/whitedigital-eu/vite-bug-error-if-env-file-contains--
Steps to reproduce
Install packages and run development environment:
npm install && npm run dev
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: