generated from hemengke1997/ts-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tsup.config.ts
47 lines (45 loc) · 939 Bytes
/
tsup.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
47
import { type Options, defineConfig } from 'tsup'
const commonConfig = (option: Options): Options => {
return {
clean: false,
sourcemap: !!option.watch,
define: {
'import.meta.vitest': 'undefined',
},
dts: true,
minify: false,
external: [/^virtual:.*/],
shims: true,
splitting: true,
treeshake: true,
}
}
export const tsup = defineConfig((option) => [
{
entry: {
'node/index': './src/node/index.ts',
},
format: ['esm'],
target: 'node16',
platform: 'node',
...commonConfig(option),
},
{
entry: {
'node/index': './src/node/index.ts',
},
noExternal: ['on-change', 'watcher'],
format: ['cjs'],
target: 'node16',
platform: 'node',
...commonConfig(option),
},
{
entry: {
'client/index': './src/client/index.ts',
},
format: ['esm', 'cjs'],
platform: 'neutral',
...commonConfig(option),
},
])