You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NX loads my vite config, then loads vite, then passes my resolved vite config object to the vite build command. The vite build command will first set NODE_ENV to the appropriate value if it's not already set. But since my vite config reads that to determine parts of the config itself, it'll read NODE_ENV before vite has a chance to set it.
Expected Behavior
Without using NX, this exact same thing works fine since vite CLI would run, which would then pass the string path of my config to the build command which then sets the environment and then loads my config. I'd expect that NX would work the same way.
There may be other differences, but I'm specifically asking if NODE_ENV can be set in the NX executor to the appropriate value (eg: "production" in the case of the production build) before evaluating my config file.
GitHub Repo
No response
Steps to Reproduce
Make a vite config which console.log(process.env.NODE_ENV)
Run the vite build command with vanilla vite and observe the output ("production")
Run the vite build command with NX vite executor and observe the output (undefined)
…node env set #27627 (#28444)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->
<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->
<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->
## Current Behavior
<!-- This is the behavior we have today -->
In the Vite Build Executor, we're using `loadConfigFromFile` from Vite
to get the config options.
The issue with this is that vite will not attempt to set `NODE_ENV`
which may be required by both the config file that is being loaded, and
other plugins.
## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Use resolveConfig which does set NODE_ENV correctly
## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->
Fixes#27627
Current Behavior
NX loads my vite config, then loads vite, then passes my resolved vite config object to the vite build command. The vite build command will first set NODE_ENV to the appropriate value if it's not already set. But since my vite config reads that to determine parts of the config itself, it'll read NODE_ENV before vite has a chance to set it.
Expected Behavior
Without using NX, this exact same thing works fine since vite CLI would run, which would then pass the string path of my config to the build command which then sets the environment and then loads my config. I'd expect that NX would work the same way.
There may be other differences, but I'm specifically asking if NODE_ENV can be set in the NX executor to the appropriate value (eg:
"production"
in the case of the production build) before evaluating my config file.GitHub Repo
No response
Steps to Reproduce
console.log(process.env.NODE_ENV)
"production"
)undefined
)Nx Report
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: