* refactor(engine): 重构2D渲染管线坐标系统 * feat(engine): 完善2D渲染管线和编辑器视口功能 * feat(editor): 实现Viewport变换工具系统 * feat(editor): 优化Inspector渲染性能并修复Gizmo变换工具显示 * feat(editor): 实现Run on Device移动预览功能 * feat(editor): 添加组件属性控制和依赖关系系统 * feat(editor): 实现动画预览功能和优化SpriteAnimator编辑器 * feat(editor): 修复SpriteAnimator动画预览功能并迁移CI到pnpm * feat(editor): 修复SpriteAnimator动画预览并迁移到pnpm * feat(editor): 修复SpriteAnimator动画预览并迁移到pnpm * feat(editor): 修复SpriteAnimator动画预览并迁移到pnpm * feat(editor): 修复SpriteAnimator动画预览并迁移到pnpm * feat(ci): 迁移项目到pnpm并修复CI构建问题 * chore: 迁移CI工作流到pnpm并添加WASM构建支持 * chore: 迁移CI工作流到pnpm并添加WASM构建支持 * chore: 迁移CI工作流到pnpm并添加WASM构建支持 * chore: 迁移CI工作流到pnpm并添加WASM构建支持 * chore: 迁移CI工作流到pnpm并添加WASM构建支持 * chore: 迁移CI工作流到pnpm并添加WASM构建支持 * chore: 移除 network 相关包 * chore: 移除 network 相关包
86 lines
2.7 KiB
JavaScript
86 lines
2.7 KiB
JavaScript
/**
|
|
* Bundle runtime files for production build
|
|
* 为生产构建打包运行时文件
|
|
*/
|
|
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname } from 'path';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
const editorPath = path.resolve(__dirname, '..');
|
|
const rootPath = path.resolve(editorPath, '../..');
|
|
const bundleDir = path.join(editorPath, 'src-tauri', 'runtime');
|
|
|
|
// Create bundle directory
|
|
if (!fs.existsSync(bundleDir)) {
|
|
fs.mkdirSync(bundleDir, { recursive: true });
|
|
console.log(`Created bundle directory: ${bundleDir}`);
|
|
}
|
|
|
|
// Files to bundle
|
|
const filesToBundle = [
|
|
{
|
|
src: path.join(rootPath, 'packages/platform-web/dist/runtime.browser.js'),
|
|
dst: path.join(bundleDir, 'runtime.browser.js')
|
|
},
|
|
{
|
|
src: path.join(rootPath, 'packages/engine/pkg/es_engine_bg.wasm'),
|
|
dst: path.join(bundleDir, 'es_engine_bg.wasm')
|
|
},
|
|
{
|
|
src: path.join(rootPath, 'packages/engine/pkg/es_engine.js'),
|
|
dst: path.join(bundleDir, 'es_engine.js')
|
|
}
|
|
];
|
|
|
|
// Copy files
|
|
let success = true;
|
|
for (const { src, dst } of filesToBundle) {
|
|
try {
|
|
if (!fs.existsSync(src)) {
|
|
console.error(`Source file not found: ${src}`);
|
|
console.log('Please build the runtime modules first:');
|
|
console.log(' npm run build --workspace=@esengine/platform-web');
|
|
console.log(' cd packages/engine && wasm-pack build --target web');
|
|
success = false;
|
|
continue;
|
|
}
|
|
|
|
fs.copyFileSync(src, dst);
|
|
const stats = fs.statSync(dst);
|
|
console.log(`✓ Bundled ${path.basename(dst)} (${(stats.size / 1024).toFixed(2)} KB)`);
|
|
} catch (error) {
|
|
console.error(`Failed to bundle ${path.basename(src)}: ${error.message}`);
|
|
success = false;
|
|
}
|
|
}
|
|
|
|
// Update tauri.conf.json to include runtime directory
|
|
if (success) {
|
|
const tauriConfigPath = path.join(editorPath, 'src-tauri', 'tauri.conf.json');
|
|
const config = JSON.parse(fs.readFileSync(tauriConfigPath, 'utf8'));
|
|
|
|
// Add runtime directory to resources
|
|
if (!config.bundle) {
|
|
config.bundle = {};
|
|
}
|
|
if (!config.bundle.resources) {
|
|
config.bundle.resources = [];
|
|
}
|
|
if (!config.bundle.resources.includes('runtime/**/*')) {
|
|
config.bundle.resources.push('runtime/**/*');
|
|
fs.writeFileSync(tauriConfigPath, JSON.stringify(config, null, 2));
|
|
console.log('✓ Updated tauri.conf.json with runtime resources');
|
|
}
|
|
}
|
|
|
|
if (!success) {
|
|
console.error('Runtime bundling failed');
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('Runtime files bundled successfully!'); |