12345678910111213141516171819202122 |
- let nodeEnv = process.env.NODE_ENV;
- let ENV_CONFIG = null;
- console.log(nodeEnv)
- if (nodeEnv === 'development') {
- //开发环境
- ENV_CONFIG = require('.env.dev.js');
- } else {
- //生产环境
- ENV_CONFIG = require('.env.prod.js');
- }
- //给环境变量process.uniEnv赋值
- if (ENV_CONFIG !== null) {
- process.uniEnv = {};
- for (let key in ENV_CONFIG) {
- process.uniEnv[key] = ENV_CONFIG[key];
- }
- // #ifdef H5
- if (nodeEnv !== 'development') {
- process.uniEnv.baseUrl = window.location.hostname;
- }
- //#endif
- }
|