// vue.config.js
configureWebpack: config => {
console.log('运行脚本:', process.env.UNI_SCRIPT)
console.log('平台:', process.env.UNI_PLATFORM)
console.log('环境:', process.env.NODE_ENV)
const externals = {}
let result = ''
for (const name in process.UNI_SCRIPT_ENV) {
if (/^VUE_APP/.test(name)) {
const value = process.UNI_SCRIPT_ENV[name]
externals[name] = 'window.' + name
result += `var ${name}="${value}";`
console.log(name, value)
}
}
}
...
}
// package.json
"uni-app": {
"scripts": {
"custom:h5:dev": {
"title": "h5-生产",
"BROWSER": "Chrome",
"env": {
"UNI_PLATFORM": "h5",
"VUE_APP_version": "1.2.0",
"VUE_APP_BASE_URL": "xxx",
"VUE_APP_BASE_IMG_URL": "xxxx"
},
"define": {
"H5-TEST": true
}
},
2 个回复
qdd (作者)
v3.2.16已修复
qdd (作者)
88,转入taro......