webpack打包VUE项目读取外部配置文件,灵活配置域名

1.在index.html中引入js

2.man.js

if (process.env.NODE_ENV === "development") {
  // 开发模式
  Vue.prototype.$SGW_URL = process.env.SGW_URL;
  Vue.prototype.$rootUrl = process.env.API_ROOT;
  Vue.prototype.$locationhref = process.env.location_href;
  Vue.prototype.$Province = process.env.Province;
  Vue.prototype.$API_City = process.env.API_City;
  Vue.prototype.$HKEZWECHAT_URL = process.env.HKEZWECHAT_URL;
  Vue.prototype.$memberhref = process.env.member_href;
  Vue.prototype.$NoSubUrl = process.env.No_SubUrl;
  Vue.prototype.$CBC_ENV = process.env.CBC_ENV;
  Vue.prototype.$SendMsg = process.env.SendMsg;
  Vue.prototype.$CanPay = process.env.CanPay;
  Vue.prototype.$vconsole = GlobConfig.vconsole;
} else {
  // 打包模式
  Vue.prototype.$SGW_URL = GlobConfig.SGW_URL;
  Vue.prototype.$rootUrl = GlobConfig.API_ROOT;
  Vue.prototype.$locationhref = GlobConfig.location_href;
  Vue.prototype.$Province = GlobConfig.Province;
  Vue.prototype.$API_City = GlobConfig.API_City;
  Vue.prototype.$HKEZWECHAT_URL = GlobConfig.HKEZWECHAT_URL;
  Vue.prototype.$memberhref = GlobConfig.member_href;
  Vue.prototype.$NoSubUrl = GlobConfig.No_SubUrl;
  Vue.prototype.$CBC_ENV = GlobConfig.CBC_ENV;
  Vue.prototype.$SendMsg = GlobConfig.SendMsg;
  Vue.prototype.$CanPay = GlobConfig.CanPay;
  Vue.prototype.$vconsole = GlobConfig.vconsole;
}

你可能感兴趣的:(webpack打包VUE项目读取外部配置文件,灵活配置域名)