angular-cli-envvars icon indicating copy to clipboard operation
angular-cli-envvars copied to clipboard

QUESTION: how you detect which environment.__NAME__.ts you should import.

Open rodriggochaves opened this issue 6 years ago • 2 comments

I just read your post on Medium. Great post!

I tried to use your solution. But a problem / question showed up: how you import the environment constant in your files? I search your repository and you use this:

import { environment } from '../../../environments/environment';

But in the post you said to change environment.ts to enviroment.dev.ts. The script set-env.ts configure this creating a copy of current environment.__NAME__.ts?

Thanks in advance!

rodriggochaves avatar Dec 24 '17 01:12 rodriggochaves

You only need to reference the environment.ts file. Angular takes care of using the right file. Here's a related post.

gldraphael avatar Feb 06 '18 10:02 gldraphael

how do you detect which environment.NAME.ts you should import?

Angular CLI does it, depending on the configuration parameter you run when building (ng build --configuration=production for instance ; in such a case Angular CLI will use environments/environment.prod.ts) By default development is assumed, which implies no suffix.

how you import the environment constant in your files?

This is the work of set-env.ts, which overwrites the relevant environments/environmentXxx.ts file which the OS env variables inserted inside thanks to the dotenv node lib.

Javarome avatar Jan 25 '19 14:01 Javarome