From 31af969ea1b529905026d9f6beb3c6bae514cbfd Mon Sep 17 00:00:00 2001 From: Olivia Tournois Date: Wed, 13 Jun 2018 10:12:53 +0200 Subject: [PATCH] docs(build): documented environment support ISSUES CLOSED: #50 --- docs/ENVIRONMENTS.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/ENVIRONMENTS.md 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. +``` +