Skip to content

Multiple env files log correctly but have a different effect #100

Open
@atollk

Description

@atollk

Hi. First of all, thanks for creating the project and keeping it active. It's a good addition that Angular is lacking.

I am trying to inject different configurations into my Angular application with @ngx-env/builder. However, it seems that the env files are not loaded correctly. I am running myapp:serve:development. This is the output when building:

---------------------------------
- Root directory:  /home/x/Projects/git/myapp/web
- Working directory:  /home/x/Projects/git/myapp/web/apps/myapp
- Files: .env
- Environment: none
- Environment files: 
 ✔ /home/x/Projects/git/myapp/web/.env
- Environment variables: NG_APP 
 ✔ NG_APP_BACKEND_API_URL
---------------------------------

Seems valid to me. However, NG_APP_BACKEND_API_URL does not actually have the value that is defined in .env, as it is suggested by that console log, but rather the value that is defined in a separate .env.development. If I delete the latter, then the correct value is used.

On the other hand, if I run NODE_ENV=devxx myapp:serve:development, this is the output:

---------------------------------
- Root directory:  /home/x/Projects/git/myapp/web
- Working directory:  /home/x/Projects/git/myapp/web/apps/myapp
- Files: .env
- Environment: devxx
- Environment files: 
 ✔ /home/x/Projects/git/myapp/web/.env.devxx
 ✔ /home/x/Projects/git/myapp/web/.env
- Environment variables: NG_APP 
 ✔ NG_APP_BACKEND_API_URL
---------------------------------

Again, completely reasonable and what I would expect. But again, that's actually not showing the truth: env.devxx is completely ignored and the values from .env are used.

So, apparently NODE_ENV is used only for logging but for the actual values, the angular build configuration is used?

Metadata

Metadata

Assignees

Labels

repo requestedReproducing repository is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions