angular - 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.
解决方案
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.
推荐阅读
- python - for 循环在运行后将值重置为 10
- javascript - 在 React Native 中使用文本转语音
- swift - iOS 14 小部件意图
- angular - 如何从 json 文件中填充下拉列表?
- sql - 边界条件问题中的 DATEDIFF 函数
- python - 如何在 tff.simulation.FilePerUserClientData 中编写正确的 dataset_fn?
- gulp - 任务从未定义:未定义
- azure-ad-b2c - How do I create a user in code, add it Azure AD B2C, then log in as that user using Azure AD B2C OAuth (MSAL)
- python - How can I use sys and argparse in same python script without getting unrecognized argument error?
- python - Atom NameError: name '' is not defined