Files
NumberSwipe_New/modes/02-connect-1234/scripts/build.mjs
T
cabinw 8026e4628d 初始提交:三玩法 Web 原型与设计文档
- 玩法一 数字一笔:规则库、求解器、26 关、竖屏触摸 Web 原型、测试
- 玩法二 连连气球:连消畅玩版核心、Web 原型、Cocos 球槽组件与导出脚本
- 玩法三 六边一笔:规则库、求解器、10 关 + 转墙实验包、Web 原型、测试
- 产品文档、UI 设计规范、各玩法 GDD / HANDOFF
- 文档移除全部外部参考作引用;删除玩法二 v0 旧稿
2026-09-16 14:30:59 +08:00

28 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import * as esbuild from 'esbuild';
import { networkInterfaces } from 'node:os';
import { mkdir, copyFile } from 'node:fs/promises';
const args = process.argv.slice(2);
const serve = args.includes('--serve');
const index = args.indexOf('--port');
const port = index >= 0 ? Number(args[index + 1]) : Number(process.env.PORT || 8002);
const ctx = await esbuild.context({
entryPoints: ['web/main.ts'], bundle: true, format: 'iife', target: 'es2020',
outfile: serve ? 'web/dist/app.js' : 'release/dist/app.js', minify: !serve, sourcemap: serve, logLevel: 'info',
define: { __DEV__: JSON.stringify(serve) },
});
if (serve) {
await ctx.watch();
const result = await ctx.serve({ host: '0.0.0.0', port, servedir: 'web' });
console.log(`\n连连气球 http://localhost:${result.port}`);
for (const item of Object.values(networkInterfaces()).flat()) {
if (item?.family === 'IPv4' && !item.internal) console.log(`手机同一 Wi-Fi: http://${item.address}:${result.port}`);
}
} else {
await mkdir('release', { recursive: true });
for (const file of ['index.html', 'style.css']) await copyFile(`web/${file}`, `release/${file}`);
await ctx.rebuild();
await ctx.dispose();
console.log('离线 / 静态发布目录:release/');
}