I'm trying to use cloud distributed caching in my project. It works fine, but there is an issue with accessToken which is placed inside nx.json. As it is a JSON, I can't set dynamic key using ENV - one for CI and one (read-only) for local use. Unfortunately I checked the DC and CLI docs and there is no alternative way (parameter) to set accessToken.
I know I can do a workaround - using fileReplacements in workspace.json/angular.json. But having a copy of this file and specifying --configuration flag just for one token is not the best approach.
To be able to use ENV to set accessToken dynamically.
No such possibility.
Angular CLI: 9.1.0
Node: 12.14.1
OS: win32 x64
Angular: 9.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.901.0
@angular-devkit/build-angular 0.901.0
@angular-devkit/build-optimizer 0.901.0
@angular-devkit/build-webpack 0.901.0
@angular-devkit/core 9.1.0
@angular-devkit/schematics 9.1.0
@ngtools/webpack 9.1.0
@schematics/angular 9.1.0
@schematics/update 0.901.0
rxjs 6.5.5
typescript 3.8.3
webpack 4.42.0
Maybe I'm missing something, because why would you give a possibility of creating multiple access tokens, but no possibility to use more than one?
You could update the nx.json via a script https://medium.com/@ferie/how-to-pass-environment-variables-at-building-time-in-an-angular-application-using-env-files-4ae1a80383c
The environment variable to set the Nx Cloud access token is NX_CLOUD_AUTH_TOKEN=(your-token-here).
If you sign into https://nx.app and go to your workspace, you can click the Workspace Options button on the top right:

There, there is documentation for different ways to setup your access token:

@FrozenPandaz Thanks for pointing a solution for that. But how can I use dotenv with that? I have multiple projects and I would prefer setting .env file locally instead of real user/system environments. I have found some alternative, but I'm already using dotenv with some worker scritps inside project, just not sure how to inject the variables inside nx CLI script.
See this issue: https://github.com/nrwl/nx/issues/3649#issuecomment-731173125
Most helpful comment
@FrozenPandaz Thanks for pointing a solution for that. But how can I use
dotenvwith that? I have multiple projects and I would prefer setting.envfile locally instead of real user/system environments. I have found some alternative, but I'm already usingdotenvwith some worker scritps inside project, just not sure how to inject the variables insidenxCLI script.