首页 > 解决方案 > Include a specific file in prod ng build

问题描述

I am developing an application where my client side is written in angular 6 and backend in dot net core WebAPI. I have created a setting.ts file that includes the URL of the WebAPI. Local URL is different than Prod URL.Each time I am deploying I need to change the URL in setting.ts. This is cumbersome.

I am wondering is there a way where I can create two setting file one for Dev and other for Prod and include Dev setting.ts only in Dev build and Prod setting.ts only in Prod build.

标签: angular

解决方案


What you're talking about is the environment.ts and environment.prod.ts files. You can also add more environment files based on your number of environments. For example: UAT. then you will use the following option to specify to build for which environment:

ng build --environment production for angular 4 or ng build --configuration production for angular 8. use ng build --help to know which syntax to follow.

I hope this helps.


推荐阅读