forked from NationalBankBelgium/stark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(build): documented environment support
ISSUES CLOSED: NationalBankBelgium#50
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
``` | ||
|