...

/

Building for Different Environments

Building for Different Environments

Learn how to build an Angular application for different environments using configuration parameters.

An organization may want to build an Angular application for multiple environments that require different variables, such as a backend API endpoint and application local settings. A common use case is a staging environment for testing the application before deploying it to production.

The Angular CLI enables us to define different configurations for each environment and build our application with each one. We can execute the ng build command (for a local machine) while passing the configuration name as a parameter using the following syntax:

ng build --configuration=name
Passing the configuration as a parameter in the ng build command

Note: We can also pass a configuration in other Angular CLI commands, such as ng serve and ng test. ...