-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add envDir: false
option
#19373
Comments
Assuming that dotenvx loads the variables to |
Hi @sapphi-red , I created the following reproduction-repository: https://github.com/Raanelom/vite-dotenvx-astro-bug-reproduction -> as you can see the variable in |
Thanks. I see. A variable that you don't expect to be loaded (placed in I think having |
Ok, it could still cause weird side-effects with the default-settings. Now that I'm aware of this behaviour I'm fine with the provided solution, but I think it'd be nice to have a more intuitive solution for users that are new to Dotenvx + Vite. |
|
It's because |
Is this about adding a |
Yes, this is about adding a |
Description
Currently, Dotenvx is not properly supported by Vite.
We are using dotenvx (from the creator of dotenv) to manage our environment variables in Astro and Vite.
This means that a
.env
and a.env.production
is available for every app in our monorepo with encrypted values, as follows:SOME_ENV_VAR="encrypted:BA/01aCs2DHMHJc2SFeg...etcetc...f1TZg="
However, this currently results in Vite picking up the encrypted values without decrypting them. This results in unexpected situations, such as: running a production build with Astro as follows:
I expect this command to only inject production .env values. However, Vite is automatically inserting the available
.env
file with encrypted values alongside the requested .env.production. This interferes with our Astro environment variable validation. We validate whether certain variables are present using Astro schema validation. Encrypted variables in the .env file are considered as "valid", even when encrypted (they are valid strings), therefore disrupting our env variable validation.We currently use a workaround by setting the envDir to "bogus" in our Astro config. This is of course not a desirable solution.
Context @ Vite Discord: https://discord.com/channels/804011606160703521/1327200673518977046
Looking forward to work towards a solution together!
Suggested solution
There are some directions:
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: