-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.config.ts
46 lines (45 loc) · 1.1 KB
/
build.config.ts
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
import { copy, readFileSync, writeFileSync } from 'fs-extra';
import path from 'path';
import { defineBuildConfig } from 'unbuild';
export default defineBuildConfig({
entries: [
'src/index',
'src/cli',
{
builder: 'mkdist',
input: 'src/chat/typechat',
outDir: 'lib/typechat',
format: 'cjs',
declaration: false,
},
],
externals: ['typechat'],
outDir: 'lib',
declaration: true,
clean: true,
rollup: {
inlineDependencies: true,
emitCJS: true,
cjsBridge: true,
esbuild: {
// minify: true,
target: 'node14',
},
alias: {
entries: {
'@': path.resolve(__dirname, 'src'),
},
},
},
failOnWarn: false,
hooks: {
'build:done': async context => {
copy(path.resolve(__dirname, 'src/assets'), path.resolve(__dirname, 'lib/assets'));
const cliCJSContent = readFileSync(path.resolve(__dirname, 'lib/cli.cjs'), 'utf8');
writeFileSync(
path.resolve(__dirname, 'lib/cli.cjs'),
cliCJSContent.replace(/require\(('|")typechat('|")\)/, `require("./typechat")`),
);
},
},
});