This seems an easy one, but I couldn't find any solution.
So, how do I check if my app is running in production mode or dev mode?
You can use this function isDevMode
import { isDevMode } from '@angular/core';
...
export class AppComponent {
constructor() {
console.log(isDevMode());
}
}
One note: be carefull with this function
if(isDevMode()) {
enableProdMode();
}
You will get
Error: Cannot enable prod mode after platform setup
environment variable
import { environment } from 'src/environments/environment';
if (environment.production) {
//
}
injected by webpack process.env.NODE_ENV variable
declare let process: any;
const env = process.env.NODE_ENV;
if (env === 'production') {
//
}