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
Nx and Vite handling conflict of .env files #239
Comments
https://github.com/chf007/vite-plugin-nx-dotenv I wrote a plugin for Vite to temporarily solve this problem. |
Cool fix @chf007! If you want, you can open a PR and add a snippet in the |
There are still some problems with the plugin: because the priority of the plugin cannot be higher than the Vite built-in define plugin, the ideal priority cannot be achieved in the At present, it may only be solved by giving pr to Vite. |
This problem has been solved in vite-plugin-nx-dotenv version 1.0.1, regardless of |
the ideal priority
/apps/[app]/.env.[mode].local
/apps/[app]/.env.[mode]
/apps/[app]/.env.local
/apps/[app]/.env
/.env.[mode].local
/.env.[mode]
/.env.local
/.env
but if there is an environment variable in both above file, the one in [mode] will not take effect
the reason is that Nx will first process
/apps/[app]/.env.local
/apps/[app]/.env
/.env.local
/.env
,and Nx does not supportmode
mode,[mode] files will not be processedwhen the Vite executor is executed, Vite will process all .env files, but at this time the environment variable Vite pre-processed by Nx will not overwrite
The text was updated successfully, but these errors were encountered: