const { execSync } = require('child_process'); //获取参数 const args = process.argv[2] //参数 const buildName = process.argv[3] //打包后的名字 const local = process.argv[4] //是否本地模式 // 执行命令并打印输出 function runCommand(command) { console.log(`执行命令: ${command}`); try { execSync(command, { stdio: 'inherit' }); } catch (error) { console.error(`命令执行失败: ${error.message}`); process.exit(1); } } // 打包前的准备 runCommand(`node ./scripts/build/config.js ${buildName} ${local}`); // 执行打包命令 runCommand('vite build'); // 恢复配置文件 runCommand('node ./scripts/build/restore.js'); // 排除打包文件 if (args === 'wgt') { runCommand('node ./scripts/build/public.js'); } // 执行打包为zip runCommand(`node ./scripts/build/zip.js ${buildName}`); console.log(`----------------------------`) console.log(`${buildName} 编译打包完成`)