-
Notifications
You must be signed in to change notification settings - Fork 2.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
feat(core): load environment variables from configuration name #17335
feat(core): load environment variables from configuration name #17335
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 1dd261d. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
This solution does not provide the proper documentation and it is not clear how to use it without having deeper knowledge of the internals of NX. I originally explored this as a quick and easy solution but I quickly realized it was untenable due to the synchronization overhead it would add to a mono repo of any size. This change requires a re-definition of every configuration in every target of every package in your mono repo, which you then need to keep in sync as you add new packages. We should think through this problem a little more and find a solution that both decreases the complexity of NX and serves the need of NX's customers. For example, this is what every target will have to become to support
|
48f0748
to
a53be8f
Compare
a53be8f
to
7781d49
Compare
Hey @SmoshySmosh. I appreciate you looking over the PR, it does also include a piece that allows Nx to infer configurations from the availability of the relevant .env files, so I think it should cover the use cases you mention. |
7781d49
to
e577641
Compare
// Inferred configuration from presence of .env files | ||
(projectHasTarget(project, target) && | ||
[ | ||
join(workspaceRoot, `.env.${configuration}`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think having a file there should define a configuration. Configurations should still be defined in the project configuration. If we'd like an easier way to define configurations, that is a separate discussion.
Can we remove this part from the changes here and consider them separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think having a file there should define a configuration. Configurations should still be defined in the project configuration. If we'd like an easier way to define configurations, that is a separate discussion.
Removing the requirement to redefine a configuration under every target is what myself and other customers are trying to get. With the current state of environment files in NX, a great deal of technical debt and configuration overhead is generated making it an unusable solution for most projects ultimately making NX very limiting.
e2e/nx-run/src/run.test.ts
Outdated
nx: { | ||
targets: { | ||
[target]: { | ||
configurations: { | ||
production: {}, | ||
}, | ||
}, | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were you going to do something with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was, yes. It looks like the e2e I had added somehow got lost 🤔
e0a6496
to
1dd261d
Compare
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Adds support for loading environment variables from .env.[configurationName] and .[configurationName].env
Fixes: #17686