ng-process-env
Advanced tools
Comparing version 14.0.1 to 14.0.2
{ | ||
"name": "ng-process-env", | ||
"version": "14.0.1", | ||
"version": "14.0.2", | ||
"description": "**ng-process-env** will help you to retrieve values from System Environment variables (process.env) and update relevant `environment.ts` file.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
# Environment variables from process into Angular app | ||
Angular already has his own environment system, can configure everything in src/environments/environment.ts | ||
and you can create as many environments as you want. | ||
The problem is, sometimes you want to use the System Environment variables, | ||
for example, some configuration from the CI server or if build process is running "on-premise" server, | ||
in this case, Angular environment system will not help. | ||
Angular already has its own environment system, which allows us to configure everything in | ||
src/environments/environment.ts, and we can create as many environments as we need. The problem is, sometimes you want | ||
to use the System Environment variables, for example, some configuration from the CI server or if the build process is | ||
running an "on-premise" server; in this case, the Angular environment system will not help. | ||
@@ -36,2 +35,3 @@ **ng-process-env** will help you to retrieve values from System Environment variables (`process.env[]`) and update | ||
``` | ||
```bash | ||
@@ -42,6 +42,8 @@ ? You can set name for config to be updated or added as a new one, 'onprem' - default | ||
Define configuration name. It will create: | ||
- `environment.<myconfig>.ts` file in your /environments folder. | ||
- `<myconfig>` section in your angular.json or project.json for nrwl managed monorepo | ||
- `environment.<myconfig>.ts` file in your /environments folder. | ||
- `<myconfig>` section in your angular.json or project.json for nrwl managed monorepo | ||
_environment.<myconfig>.ts_ | ||
```typescript | ||
@@ -60,3 +62,5 @@ export const environment = { | ||
``` | ||
_angular.json_ \ _project.json_ | ||
```json | ||
@@ -84,7 +88,8 @@ { | ||
## Collect Vars | ||
## Collect Vars | ||
Open a created file `environment.<myconfig>.ts` | ||
Update `envVar` section with variables you want to be retrieved from `process.env`. | ||
- **Important**: set default values. | ||
@@ -104,4 +109,5 @@ | ||
## _This part can be run during CI/CD process_ | ||
To update the created environment.<myconfig>.ts file with variables from `process.env`. | ||
To update the created environment.<myconfig>.ts file with variables from `process.env`. | ||
```bash | ||
@@ -112,11 +118,13 @@ export myVarA=4 | ||
``` | ||
It will change file to: | ||
```typescript | ||
export const environment = { | ||
production: false, | ||
baseUrl: "http://localhost:4200", | ||
envVar: { | ||
myVarA: 4 as number, | ||
myVarB: "otherValue" | ||
} | ||
production: false, | ||
baseUrl: "http://localhost:4200", | ||
envVar: { | ||
myVarA: 4 as number, | ||
myVarB: "otherValue" | ||
} | ||
}; | ||
@@ -123,0 +131,0 @@ ``` |
73976
128