|
@@ -86,7 +86,9 @@ export class BuildService {
|
|
|
await this.collectOutput(buildOutputDir, platform, results);
|
|
await this.collectOutput(buildOutputDir, platform, results);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 5. 复制默认产物到预览目录(供真机扫码测试)
|
|
|
|
|
|
|
+ // 5. 构建默认产物(无 --mode,用于真机扫码测试)
|
|
|
|
|
+ console.log(`[build] Building default for preview...`);
|
|
|
|
|
+ await this.runViteBuild("default", "");
|
|
|
const defaultDist = path.join(TEMPLATE_DIR, "dist", "index.html");
|
|
const defaultDist = path.join(TEMPLATE_DIR, "dist", "index.html");
|
|
|
const previewDir = path.join(this.storageDir, "previews");
|
|
const previewDir = path.join(this.storageDir, "previews");
|
|
|
ensureDir(previewDir);
|
|
ensureDir(previewDir);
|
|
@@ -94,7 +96,7 @@ export class BuildService {
|
|
|
fs.copyFileSync(defaultDist, previewPath);
|
|
fs.copyFileSync(defaultDist, previewPath);
|
|
|
console.log(`[build] Preview file: ${previewPath}`);
|
|
console.log(`[build] Preview file: ${previewPath}`);
|
|
|
|
|
|
|
|
- // 6. 打包 ZIP
|
|
|
|
|
|
|
+ // 7. 打包 ZIP
|
|
|
await this.createZip(buildOutputDir, results);
|
|
await this.createZip(buildOutputDir, results);
|
|
|
|
|
|
|
|
// 6. 更新数据库
|
|
// 6. 更新数据库
|
|
@@ -129,9 +131,10 @@ export class BuildService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private runViteBuild(platform: string): Promise<void> {
|
|
|
|
|
|
|
+ private runViteBuild(platform: string, modeFlag?: string): Promise<void> {
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
- const cmd = `cd ${TEMPLATE_DIR} && AD_CONFIG_PATH=src/filler/_ad_config_.ts npx vite build --mode ${platform}`;
|
|
|
|
|
|
|
+ const mode = modeFlag ?? `--mode ${platform}`;
|
|
|
|
|
+ const cmd = `cd ${TEMPLATE_DIR} && AD_CONFIG_PATH=src/filler/_ad_config_.ts npx vite build ${mode}`.trim();
|
|
|
console.log(`[build] Executing: ${cmd}`);
|
|
console.log(`[build] Executing: ${cmd}`);
|
|
|
|
|
|
|
|
exec(cmd, { timeout: BUILD_TIMEOUT_MS }, (error, stdout, stderr) => {
|
|
exec(cmd, { timeout: BUILD_TIMEOUT_MS }, (error, stdout, stderr) => {
|