So my Angular application on prod is running in devmode. The two environments i have are:
environment.ts:
export const environment = new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open('GET', './assets/config/config.json');
xhr.onload = function () {
if (xhr.status === 200) {
const config = JSON.parse(xhr.responseText);
config['production'] = false;
resolve(config);
} else {
reject('Cannot load configuration...');
}
};
xhr.send();
});
environment.prod.ts:
export const environment = new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open('GET', './assets/config/config.json');
xhr.onload = function () {
if (xhr.status === 200) {
const config = JSON.parse(xhr.responseText);
config['production'] = true;
resolve(config);
} else {
reject('Cannot load configuration...');
}
};
xhr.send();
});
I saw that enableProdMode() in main.ts is called depending on whether im in prod or not.
import {environment as environmentPromise} from './environments/environment';
environmentPromise.then(environment => {
if (environment['production']) {
enableProdMode();
}
localStorage.setItem('authServer', environment['authServer']);
localStorage.setItem('resourceServer', environment['resourceServer']);
platformBrowserDynamic().bootstrapModule(AppModule);
});
But first of all, environment is imported from environment.ts here. So environment['production'] is always false. The exported environemnt from environment.prod.ts is unused. How do i do check whether im in prod or not correctly then?