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.