It is possible to define…

1 minute read

It is possible to define custom ENV variables or file in workspaces.json?


We use environment.ts and for managing environment variables. Is there a reason you don’t want to go that route?

I need more enviroments, something like: nx serve --env=qa

<> ?

yes, or test, or dev

you should be able to achieve that with new environment.<env>.ts files and add different configurations to your workspace.json or angular.json file, maybe? that would work assuming your running a build per environment.

if you only want to run one build for every environment, I would suggest some sort of Valut, AWS SSM, Parameter Store type service to store those things, and get the values at startup

sorry, my brain is in backend land lately, is this for FE app or BE service?

It is a React app

What I have right now is several .env.{environment} files

Then npm scripts that run env-cmd -f .<|> nx serve

That works

gotcha, for our FE app we have a step in our deployment that gets some parameters out of aws and generates an env.js file and puts it in the bundle during deployment. The front end includes that file with a basic &lt;script&gt; tag. all that is in the file is a couple window.{NAMESPACE_ENV_VAR} = 'blah';

an option I suppose