Skip to content
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

fix: Prevent NX from loading .env files when running CLI scripts. #477

Merged
merged 3 commits into from
Feb 15, 2024

Conversation

pziemkowski
Copy link
Member

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines

What kind of change does this PR introduce?

Bug fix
Closes #475

What is the current behavior?

NX loads .env files from webapp and backend packages when running CLI commands. Some of variables are interfering with the execution of the script. They should only be loaded by Docker or Vite during runtime of apps, not scripts.

What is the new behavior?

Patched nx package to prevent this behaviour with an ENV variable set within CLI.

Does this PR introduce a breaking change?

Not a breaking change but if someone used .env files in a wrong way that could cause conflict.

@@ -48,6 +48,10 @@ export async function loadVersionEnv() {
return version;
}

export const loadNxEnv = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this name... It should be sth like disableNxEnv for example

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, ok. I was rather thinking it's a good place to put other NX-related envs in the future if necessary

Copy link
Contributor

@mkleszcz mkleszcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look on my comment

@mkleszcz mkleszcz merged commit db0a868 into master Feb 15, 2024
53 checks passed
@mkleszcz mkleszcz deleted the fix/env-files-nx branch February 15, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enviroment variables loaded from .env file during backend build.
2 participants