2025-11-18 14:46:51 +08:00
|
|
|
const resolve = require('@rollup/plugin-node-resolve');
|
|
|
|
|
const commonjs = require('@rollup/plugin-commonjs');
|
2025-11-25 22:23:19 +08:00
|
|
|
const replace = require('@rollup/plugin-replace');
|
2025-11-18 14:46:51 +08:00
|
|
|
const dts = require('rollup-plugin-dts').default;
|
|
|
|
|
const postcss = require('rollup-plugin-postcss');
|
|
|
|
|
|
|
|
|
|
const external = [
|
2025-11-25 22:23:19 +08:00
|
|
|
'@esengine/editor-runtime',
|
2025-11-18 14:46:51 +08:00
|
|
|
'@esengine/behavior-tree',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
module.exports = [
|
|
|
|
|
{
|
|
|
|
|
input: 'bin/index.js',
|
|
|
|
|
output: {
|
|
|
|
|
file: 'dist/index.esm.js',
|
|
|
|
|
format: 'es',
|
|
|
|
|
sourcemap: true,
|
|
|
|
|
exports: 'named',
|
|
|
|
|
inlineDynamicImports: true
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
2025-11-25 22:23:19 +08:00
|
|
|
replace({
|
|
|
|
|
preventAssignment: true,
|
|
|
|
|
'process.env.NODE_ENV': JSON.stringify('production')
|
|
|
|
|
}),
|
2025-11-18 14:46:51 +08:00
|
|
|
resolve({
|
|
|
|
|
extensions: ['.js', '.jsx']
|
|
|
|
|
}),
|
|
|
|
|
postcss({
|
|
|
|
|
inject: true,
|
|
|
|
|
minimize: false
|
|
|
|
|
}),
|
|
|
|
|
commonjs()
|
|
|
|
|
],
|
|
|
|
|
external,
|
|
|
|
|
onwarn(warning, warn) {
|
|
|
|
|
if (warning.code === 'CIRCULAR_DEPENDENCY' || warning.code === 'THIS_IS_UNDEFINED') {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
warn(warning);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 类型定义构建
|
|
|
|
|
{
|
|
|
|
|
input: 'bin/index.d.ts',
|
|
|
|
|
output: {
|
|
|
|
|
file: 'dist/index.d.ts',
|
|
|
|
|
format: 'es'
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
dts({
|
|
|
|
|
respectExternal: true
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
external: [
|
|
|
|
|
...external,
|
2025-11-25 22:23:19 +08:00
|
|
|
/\.css$/,
|
|
|
|
|
// 排除 React 相关类型,避免 rollup-plugin-dts 解析问题
|
|
|
|
|
'react',
|
|
|
|
|
'react-dom',
|
|
|
|
|
/^@types\//,
|
|
|
|
|
/^@esengine\//
|
2025-11-18 14:46:51 +08:00
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
];
|