1234567891011121314151617181920212223 |
- let nodeEnv = process.env.NODE_ENV;
- let ENV_CONFIG = null;
- console.log(nodeEnv)
- nodeEnv = 'development'
- 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
- }
|