This commit is contained in:
2025-02-28 03:05:52 +08:00
parent 5e29dd2a0d
commit b6b11899f1
20 changed files with 1132 additions and 53 deletions

View File

@@ -6,9 +6,11 @@ import esbuild from 'rollup-plugin-esbuild';
import alias from '@rollup/plugin-alias';
import replace from '@rollup/plugin-replace';
import pkgs from './package.json' with {type: 'json'};
import typescript from '@rollup/plugin-typescript';
const isDev = process.env.NODE_ENV === 'development';
const input = isDev ? './src/dev.ts' : './src/index.ts';
console.log('isDev:', isDev, 'input:', input);
/**
* @type {import('rollup').RollupOptions}
*/
@@ -30,46 +32,31 @@ const config = {
// only esbuild needs to be configured
entries: [
{ find: '@', replacement: path.resolve('src') }, // 配置 @ 为 src 目录
{ find: 'http', replacement: 'node:http' },
{ find: 'https', replacement: 'node:https' },
{ find: 'fs', replacement: 'node:fs' },
{ find: 'path', replacement: 'node:path' },
{ find: 'crypto', replacement: 'node:crypto' },
{ find: 'zlib', replacement: 'node:zlib' },
{ find: 'stream', replacement: 'node:stream' },
{ find: 'net', replacement: 'node:net' },
{ find: 'tty', replacement: 'node:tty' },
{ find: 'tls', replacement: 'node:tls' },
{ find: 'buffer', replacement: 'node:buffer' },
{ find: 'timers', replacement: 'node:timers' },
// { find: 'string_decoder', replacement: 'node:string_decoder' },
{ find: 'dns', replacement: 'node:dns' },
{ find: 'domain', replacement: 'node:domain' },
{ find: 'os', replacement: 'node:os' },
{ find: 'events', replacement: 'node:events' },
{ find: 'url', replacement: 'node:url' },
{ find: 'assert', replacement: 'node:assert' },
{ find: 'util', replacement: 'node:util' },
// { find: '@kevisual/code-center-module', replacement: path.resolve('node_modules/@kevisual/code-center-module') },
],
}),
resolve({
preferBuiltins: true, // 强制优先使用内置模块
preferBuiltins: true,
}),
commonjs(),
esbuild({
target: 'node22', //
minify: false, // 启用代码压缩
tsconfig: 'tsconfig.json',
include: [
"src/**/*.ts",
]
}),
json(),
],
external: [
/@kevisual\/router(\/.*)?/, //, // 路由
/@kevisual\/use-config(\/.*)?/, //
// 'sequelize', // 数据库 orm
// 'ioredis', // redis
// 'pg', // pg
/@kevisual\/code-center-module(\/.*)?/, //
'sequelize', // 数据库 orm
'ioredis', // redis
'pg', // pg
],
};
export default config;