Can I pass arguments to angular-cli at build-time

It is possible to create multiple configuration files with @angular/cli.

As mentioned in docs custom configuration files can be add in the following way:

  • create a src/environments/environment.NAME.ts
  • add { "NAME": 'src/environments/environment.NAME.ts' } to the apps[0].environments object in .angular-cli.json
  • use them via the --env=NAME flag on the build/serve commands.

So, you would probably need 6 config files for dev and 6 config files for prod.

And then to access those variables just import environment object from environment.ts file.

Leave a Comment