Ionic serve using production environment - which I don't want


when I run ionic serve -w chrome, it uses instead of environment.ts

I tried tweaking in angular.json, the part of fileReplacements in configuration to see if that is part of the issue, but does not seem to be.

The “serve” part in angular.json shows a configuration,production key, but I assume that one is only triggered when using --prod flag (which I don’t use).

WHen I run ionic serve -w chrome --prod, it does show ng.cmd run app:serve:production --host=localhost --port=8100, (whereas without --prod it shows ng.cmd run app:serve --host=localhost --port=8100)

What am I doing wrong here? Any hints?

I am not very comfortable changing much of the scripts parts for a nearly production app, so any help will be appreciated.


in addition this, when i console.log in app.component.ts the environment it should the dev keys, but the subsequent page uses the prod keys…

How odd…

Anyone have a clue what I am doing here?



Found it!

While referencing to the environmnent object in the environment.ts file in a ts file, the auto-import used instead of environment.ts and as such there was no replacement…

Silly me.

How did I find out: by renaming and the see which part would complain.

Thanks for bearing with me :slight_smile: