'What does the production property do in environment.ts?

In an Angular project's environment files, what happens when the production property is set to true vs when it's set to false?

We have multiple prod environment files - each is used for a different region. I noticed one of their production properties is set to false, even though it's a prod environment file. Does this make the binaries larger, among other bad stuff for prod builds?



Solution 1:[1]

The production property is just there so that you can look at environment.production and write debug code when it is false. It will not have any affect on your build or code unless you have lines your code that check for that flag. Your environment file in general is more of a config file that you can use for your own use cases. Angular picks a different environment file based on your build parameters and your configurations in your angular.json file.

check this out: https://angular.io/guide/build and also take a look at the Configure target-specific file replacements section.

Basically if you have a environment.staging.ts and a configuration for staging in your angular.json file, you can run ng build --configuration=staging to use those variables for that build.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rleffler