Angular - Overwrite (only) one property of the environment

1.3k views Asked by At

I have an Angular application and I have created different environmet for different clients:

{
name: client1,
address: client 1 address,
... a lot of variables
variableToChange: thisWantModify
}

and everything works fine for me when I do

ng serve --configuration = client1

or

ng build --configuration = client1

The variables works ok.

The problem I have is that I want to change the value of that (and only that) variable (ToChange variable) when I do

ng build --configuration = client1

I know that one solution would be to duplicate the environment and use

ng build --configuration = client1build

but I have many clients and it would double the amount of environment files.

Is possible to do it in other way?

Thank you

1

There are 1 answers

0
user2599052 On

One way to achieve this is to have placeholders in your environment.ts file for the properties that might require override within a environment. Then create a custom script which will replace that placeholder with appropriate value and then invoke ng build.