21 lines
626 B
JavaScript
21 lines
626 B
JavaScript
import { build } from 'esbuild';
|
|
|
|
build({
|
|
entryPoints: ['./server.tsx'], // 入口文件
|
|
bundle: true, // 打包所有依赖
|
|
outfile: './server.js', // 输出文件
|
|
minify: false, // 压缩代码
|
|
sourcemap: false, // 生成 Source Map
|
|
platform: 'node', // 指定运行环境为浏览器
|
|
target: ['es6'], // 目标环境
|
|
external: ['node_modules/*'], // 不打包 node_modules
|
|
loader: { '.jsx': 'jsx', '.tsx': 'tsx', '.js': 'jsx' }, // 处理 JSX 文件
|
|
})
|
|
.then(() => {
|
|
console.log('Client build complete!');
|
|
})
|
|
.catch((err) => {
|
|
console.error('Build failed:', err);
|
|
process.exit(1);
|
|
});
|