fix(worker-generator): 映射文件不再放入 workers 目录避免微信编译错误
This commit is contained in:
30
examples/wechat-worker-demo/build.js
Normal file
30
examples/wechat-worker-demo/build.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 构建脚本 - 打包为微信小游戏可用的 JS 文件
|
||||
* Build script - bundle for WeChat Mini Game
|
||||
*/
|
||||
const esbuild = require('esbuild');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const outDir = path.join(__dirname, 'dist');
|
||||
|
||||
// 确保输出目录存在
|
||||
if (!fs.existsSync(outDir)) {
|
||||
fs.mkdirSync(outDir, { recursive: true });
|
||||
}
|
||||
|
||||
// 打包主程序
|
||||
esbuild.buildSync({
|
||||
entryPoints: ['src/index.ts'],
|
||||
bundle: true,
|
||||
outfile: 'dist/game-bundle.js',
|
||||
format: 'iife',
|
||||
globalName: 'GameDemo',
|
||||
target: ['es2015'],
|
||||
platform: 'browser',
|
||||
external: [], // 不排除任何依赖,全部打包
|
||||
minify: false,
|
||||
sourcemap: true,
|
||||
});
|
||||
|
||||
console.log('Build complete: dist/game-bundle.js');
|
||||
Reference in New Issue
Block a user