How to check if Angular application running in Production or Development mode

前端 未结 6 620
挽巷
挽巷 2020-12-07 17:27

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?

6条回答
  •  星月不相逢
    2020-12-07 17:38

    Simply check the production variable present in the environment file, it will be true for production mode and false for development.

    import { environment } from 'src/environments/environment';
    
    if (environment.production) {
      // for production
    } else {
      // for development
    }
    

提交回复
热议问题