-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
52 lines (51 loc) · 1.25 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { copyFileSync, existsSync, mkdirSync } from 'fs';
import { dirname, join } from 'path';
export default {
input: 'src/bin/cli.ts',
output: [
{
file: 'dist/cli.js',
format: 'esm',
sourcemap: true,
banner: '#!/usr/bin/env node',
},
],
external: [
// List external dependencies that shouldn't be bundled
'chalk',
'commander',
'gpt-tokenizer',
'minimatch',
'ora',
'yaml',
'bun', // Add bun as an external dependency
],
plugins: [
resolve({
preferBuiltins: true,
}),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
noEmit: false, // Ensure noEmit is false for Rollup
}),
{
name: 'copy-config',
writeBundle() {
// 确保目标目录存在
const configDir = join('dist', 'config');
if (!existsSync(configDir)) {
mkdirSync(configDir, { recursive: true });
}
// 复制配置文件
copyFileSync(
join('src', 'config', 'defaultConfig.yaml'),
join('dist', 'config', 'defaultConfig.yaml')
);
},
},
],
};