2025-11-25 22:23:19 +08:00
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
|
import { resolve } from 'path';
|
|
|
|
|
import dts from 'vite-plugin-dts';
|
|
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [
|
|
|
|
|
dts({
|
|
|
|
|
include: ['src'],
|
|
|
|
|
outDir: 'dist',
|
2025-11-27 20:42:46 +08:00
|
|
|
rollupTypes: false,
|
|
|
|
|
tsconfigPath: './tsconfig.json'
|
2025-11-25 22:23:19 +08:00
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
define: {
|
|
|
|
|
'process.env.NODE_ENV': JSON.stringify('production')
|
|
|
|
|
},
|
|
|
|
|
esbuild: {
|
|
|
|
|
// 保留类名,用于跨包插件服务匹配
|
|
|
|
|
keepNames: true,
|
|
|
|
|
},
|
|
|
|
|
build: {
|
|
|
|
|
lib: {
|
|
|
|
|
entry: resolve(__dirname, 'src/index.ts'),
|
|
|
|
|
formats: ['es'],
|
|
|
|
|
fileName: () => 'editor-runtime.js'
|
|
|
|
|
},
|
|
|
|
|
rollupOptions: {
|
2025-11-27 20:42:46 +08:00
|
|
|
// 将 React 和核心 ECS 框架设为外部依赖
|
|
|
|
|
// 这确保整个应用使用同一个 ComponentRegistry 实例
|
|
|
|
|
external: [
|
|
|
|
|
'react',
|
|
|
|
|
'react-dom',
|
|
|
|
|
'react/jsx-runtime',
|
|
|
|
|
'@esengine/ecs-framework',
|
|
|
|
|
'@esengine/ecs-components',
|
|
|
|
|
'@esengine/tilemap',
|
|
|
|
|
'@esengine/ui',
|
|
|
|
|
'@esengine/behavior-tree',
|
|
|
|
|
'@esengine/platform-web',
|
|
|
|
|
'@esengine/ecs-engine-bindgen',
|
|
|
|
|
'@esengine/asset-system',
|
|
|
|
|
],
|
2025-11-25 22:23:19 +08:00
|
|
|
output: {
|
|
|
|
|
exports: 'named',
|
|
|
|
|
inlineDynamicImports: true,
|
|
|
|
|
// 映射外部依赖到全局变量
|
|
|
|
|
globals: {
|
|
|
|
|
'react': 'React',
|
|
|
|
|
'react-dom': 'ReactDOM',
|
|
|
|
|
'react/jsx-runtime': 'ReactJSXRuntime'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
target: 'es2020',
|
|
|
|
|
minify: false,
|
|
|
|
|
sourcemap: true
|
|
|
|
|
}
|
|
|
|
|
});
|