Closed usarskyy closed 1 month ago
Mysterious issue is solved: my IDE directly imported environment.prod.ts
file, not environment.ts
as I expected. Unfortunately I haven't noticed it immediately and wasted lots of time on this problem.
Good news: by experimenting with my project setup I found another bug. So, I tried to add fileReplacements
to development
configuration and replace a file with itself (I know, sounds stupid but I was desperate :) )
Suddenly I got an error saying The E:\ROOT_PROJECT_PATH\src\environments\environment.ts path in file replacements does not exist.
This is weird because I added fileReplacements
into angular's application project.json file located in directory E:\ROOT_PROJECT_PATH\apps\APP_NAME\
, root project.json file wasn't modified. Then I found out that path in fileReplacements
is relative to the root directory, not to the app's directory. I could confirm it by launching my app using --configuration=production
parameter that failed immediately with the similar error message.
I expect that if I configure file replacement in E:\ROOT_PROJECT_PATH\apps\APP_NAME\project.json
, all my paths are relative to this project.json
, not to the root project.json
.
Hi @usarskyy, glad to know you are unblocked on your original issue. As for the paths in project.json
, they are always assumed to be relative to the workspace root, not project root, so this is working as intended.
Are you running into any other issue?
@jaysoo As for me this behavior looks a bit weird but I am happy it is not a bug :)
It would be great if someone could mention this piece of info in all comments for fileReplacements
.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
I start one of the apps using
nx serve MY_APP_NAME
command. My app has a directory calledenvironments
with three files in it:environment.ts
environment.test.ts
environment.prod.ts
In
project.json
I configuredfileReplacements
forproduction
andtest
configurations but not fordevelopment
.When I run
nx server MY_APP_NAME
, I can see that NX executesnx run MY_APP_NAME:serve:development
and this target has the followingbuidTarget
in it:I don't understand why environment.ts file gets replaced with environment.prod.ts.
nx reset
didn't help.Expected Behavior
environment.ts file should not be replaced with environment.prod.ts
GitHub Repo
No response
Steps to Reproduce
Nx Report
Node : 18.19.1 OS : win32-x64 Native Target : x86_64-windows npm : 10.2.4
nx (global) : 20.0.0 nx : 20.0.0 @nx/js : 20.0.0 @nx/jest : 20.0.0 @nx/eslint : 20.0.0 @nx/workspace : 20.0.0 @nx/angular : 20.0.0 @nx/devkit : 20.0.0 @nx/eslint-plugin : 20.0.0 @nx/playwright : 20.0.0 @nx/vite : 20.0.0 @nx/web : 20.0.0 @nx/webpack : 20.0.0 typescript : 5.5.4
Registered Plugins: @nx/playwright/plugin @nx/eslint/plugin
Community plugins: @ngrx/router-store : 18.1.0 @ngrx/store : 18.1.0 @ngrx/store-devtools : 18.1.0
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
No response