|
|
@@ -4,8 +4,9 @@ const { execSync } = require('child_process');
|
|
|
const path = require('path');
|
|
|
const fs = require('fs');
|
|
|
|
|
|
-const TARO_API_URL = 'http://localhost:6001'; // 远程地址,这里写死,要做成部署后可配置
|
|
|
-const TARO_MQTT_URL ='ws://localhost:8083/mqtt';
|
|
|
+// 优先使用环境变量,如果不存在则使用默认值(支持部署后可配置)
|
|
|
+const TARO_API_URL = process.env.TARO_API_URL || 'http://localhost:6001';
|
|
|
+const TARO_MQTT_URL = process.env.TARO_MQTT_URL || 'ws://localhost:8083/mqtt';
|
|
|
const rootDir = path.join(__dirname, '..'); // 项目根目录
|
|
|
|
|
|
try {
|
|
|
@@ -23,7 +24,8 @@ try {
|
|
|
console.log(`复制arm平台必须构建文件taro.linux-arm64-gnu.node到目标位置===完成`);
|
|
|
}
|
|
|
|
|
|
- execSync(`npm run build:h5`, { cwd: rootDir, stdio: 'inherit', env: { ...process.env, TARO_API_URL ,TARO_MQTT_URL} }, (error, stdout, stderr) => {
|
|
|
+ // 将读取的环境变量传递给子进程
|
|
|
+ execSync(`npm run build:h5`, { cwd: rootDir, stdio: 'inherit', env: { ...process.env, TARO_API_URL, TARO_MQTT_URL } }, (error, stdout, stderr) => {
|
|
|
if (error) {
|
|
|
console.error(`Error executing command: ${error.message}`);
|
|
|
return;
|