I'm using Angular-cli 1.4.4, and i'm unable to use environments properly
I have this :
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts",
"qa": "environments/environment.qa.ts"
}
When I build with my qa environment it uses prod configuration
I ran this: ng build --env=qa
@AnthonyGiretti can you put up a repository on github that shows this problem happening please? I cannot reproduce locally with the information you have given.
Hi @filipesilva thank you for your reply!
Yes you can find it here
https://github.com/AnthonyGiretti/Angular4-IgniteUI.git
Can't wait to hear from you!
Anthony
I am having a similar issue
ng build --env=prod is always picking environment.ts instead of environment.prod.ts is this a bug?
I guess its because main.ts imports environment.ts by default
import { environment } from './environments/environment';
If main.ts imports environment.prod.ts, that gets picked up all the time.
import { environment } from './environments/environment.prod.ts';
https://stackoverflow.com/questions/46573559/angular4-enable-production-mode
Hi, any update on this?
I'm having the same issue. This was working before I updated to the latest version of angular 4. My project was started in Angular 4.2
I believe as @hmajumdar that the main is not getting overridden.
Example of my setup:
"environmentSource": "environments/environment",
"environments": {
"local-us": "environments/us/environment.local.ts",
"dev-us": "environments/us/environment.dev.ts",
"qa-us": "environments/us/environment.qa.ts",
"prod-us": "environments/us/environment.prod.ts",
"local-au": "environments/us/environment.local.ts",
"dev-au": "environments/au/environment.ts",
"qa-au": "environments/au/environment.qa.ts",
"prod-au": "environments/au/environment.prod.ts"
}
You need to set the聽envName聽in the environment Object for all the environments , something like this
export const environment = {
production: true,
apiURL : '/offer-screener-web/'
envName: 'prod'
};
@pearpages Yea I know that. Each file has it's own environment values all with the same object attributes. The CLI just isn't loading the file that is specified in the angular-cli.json
ie. ng build --env=dev-us like I have in my setup. It used to until I updated to the latest version.
we are using 1.4.9 here and seems that all is ok, and we also use a path mapping on tsconfig too...
"environmentSource": "environments/environment.ts",
"environments": {
"local": "environments/environment.local.ts",
"dev": "environments/environment.ts",
"qa": "environments/environment.qa.ts",
"prod": "environments/environment.prod.ts"
}

Here's an example of my dev configs.
//"dev-us": "environments/us/environment.dev.ts"
export const environment = {
production: false,
envName: 'dev',
apiUrl: 'https://max.biz/',
translationAssetPath: '/bundles/maxangular/assets/i18n/',
defaultLocale: 'en_US',
supportedLocalesPath: '/bundles/maxangular/assets/locales/locales.us.json'
};
Is there something obviously wrong?
HI guys,
Sorry for everything, I finally found my issue, after upgrading to angular CLI 1.4.9 I let in my code prod configuration call like this : import { environment } from './../../environments/environment.prod';
With 1.4.9 version I have no longer the issue !!
This topic could be closed I think
@AnthonyGiretti Thats not how it is supposed to work. Ideally one should use import { environment } from './../../environments/environment' and whatever environment name you pass in command line should be used. Search for my comment above.
Hi,
sorry for missunderstanding, i meant I had this issue with older angular-cli version then I upgraded to 1.4.9 and it worked fine, but i have also put import { environment } from './../../environments/environment.prod to execute my website in production mode and i forgot to remove it. sorry lol
Thanks everybody!
Closing as it seems like the issue was sorted.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
@AnthonyGiretti Thats not how it is supposed to work. Ideally one should use
import { environment } from './../../environments/environment'and whatever environment name you pass in command line should be used. Search for my comment above.