diff --git a/docs/ENVIRONMENTS.md b/docs/ENVIRONMENTS.md new file mode 100644 index 0000000000..a424bc28e0 --- /dev/null +++ b/docs/ENVIRONMENTS.md @@ -0,0 +1,43 @@ +# Environments support + +## Environment.ts + +In the `src/environments/model.ts` is provided the Environment interface as follows + +``` +... +export interface Environment { + production: boolean; + hmr: boolean; + ... +``` + +`production`, which is a boolean, will specify is your application runs under a production environment, +while `hmr` will indicate if it runs under a Hot Module Replacement environment. + +This interface will then be defined by default in `src/environments/environment.ts`: +``` +... +export const environment: Environment = { + production: false, + hmr: false, + showDevModule: true, + ... +``` + +## How to find out which environment is your application is currently using? + +All you have to do is to import in your app.module.ts file the environment.ts constant +``` +import { environment } from "../environments/environment"; +``` + +This way, you will be able to programmatically determine which environment is used in your app +with simple checks, as follows: + +``` +environment.production +// if the output of this line is true, we are in production environment. +// Otherwise, we are in hmr environment. +``` +