My angular-cli.json
has environments array.
"environmentsSource": "environments/environment.ts"
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
In environment.ts
,
export const environment = {
production: false
};
In environment.prod.ts
export const environment = {
production: true
};
And in main.ts
,
if (environment.production) {
enableProdMode();
}
However I only have one package.josn
file.
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build"
I have different environments such as dev/qa and prod. The urls are different, how can I switch the mode for just one package.json file?
The build and deploy process is automatedly. We can't change the setting when build.
In main.ts
, I checked the value of document.location.host
. If it contains a specific substring then I
enableProdMode()