.env.js 580 B

1234567891011121314151617181920212223
  1. let nodeEnv = process.env.NODE_ENV;
  2. let ENV_CONFIG = null;
  3. console.log(nodeEnv)
  4. nodeEnv = 'development'
  5. if (nodeEnv === 'development') {
  6. //开发环境
  7. ENV_CONFIG = require('.env.dev.js');
  8. } else {
  9. //生产环境
  10. ENV_CONFIG = require('.env.prod.js');
  11. }
  12. //给环境变量process.uniEnv赋值
  13. if (ENV_CONFIG !== null) {
  14. process.uniEnv = {};
  15. for (let key in ENV_CONFIG) {
  16. process.uniEnv[key] = ENV_CONFIG[key];
  17. }
  18. // #ifdef H5
  19. if (nodeEnv !== 'development') {
  20. process.uniEnv.baseUrl = window.location.hostname;
  21. }
  22. //#endif
  23. }