官术网_书友最值得收藏!

Environments

Inside of the src/environments folder, we find two configuration files. One is called environment.prod.ts, and the other is environment.ts. The Angular CLI will know what to use, depending on the command that we use; for example, consider the following command:

 ng build --env = prod 

If we use it, then Angular will use the environment.prod.ts file, and, for the other commands, such as ng serve, it will use environment.ts. This is very useful, especially when we have a local API and one in production, using different paths.

Both files have almost the same code; see environment.prod.ts, as follows:

export const environment = {
production: true
};

The environment.ts file is as follows:

export const environment = {
production: false
};

Note that the Boolean true (on production) and false (on development) is the only difference between the two files, at this first stage. It is clear that, in addition to the files that we mentioned, we have a lot of other files within an Angular application, and all of them are extremely important. But, for now, let's focus on these. Don't worry; throughout the course of the book, we will look at more of them in detail, during the development of our example application. For now, we are going to focus on creating the simple example that we are using in this chapter.

主站蜘蛛池模板: 宜兰县| 和田市| 互助| 福安市| 抚州市| 西充县| 开江县| 滨州市| 苏尼特右旗| 徐州市| 弥勒县| 成武县| 航空| 竹山县| 五峰| 万安县| 红原县| 定州市| 淮安市| 攀枝花市| 乌拉特中旗| 丰都县| 定西市| 右玉县| 民县| 罗平县| 东丽区| 吉林省| 恩施市| 高雄县| 陇南市| 辉县市| 泰州市| 凌源市| 育儿| 股票| 高陵县| 策勒县| 西乡县| 宁陕县| 平果县|