Configure and build Angular application for different environments

Balram Chavan
2 min readJan 25, 2019

By default Angular application can be built to development environment or to production environment. Based on target environment, your application might have different setup. For example, API URL to fetch data from server.

Production mode:

You can build your application in production mode by running command:

ng build --prod

When application is built for production mode then environments/environment.ts file gets replaced with environments/environment.prod.ts file. Hence if you are referring to settings from environment.ts file in your code, you don’t have to put any if condition or hard code production URL.

You can find detailed information how to separate production URL in my other blog.

What about custom environment modes?

--

--

Balram Chavan
Balram Chavan

Written by Balram Chavan

Google Developer Expert Angular | Architect | Author | http://www.youtube.com/@angularcloud

Responses (14)