generated from hemengke1997/ts-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tsup.config.ts
55 lines (53 loc) · 1.16 KB
/
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
48
49
50
51
52
53
54
55
import { defineConfig, type Options } from 'tsup'
import { bundleless } from 'tsup-plugin-bundleless'
const commonConfig = (option: Options): Options => {
return {
dts: true,
clean: !option.watch,
minify: false,
format: ['cjs', 'esm'],
sourcemap: !!option.watch,
treeshake: true,
external: [/^virtual:.*/],
}
}
export const tsup = defineConfig((option) => [
{
...commonConfig(option),
entry: ['./src/client/**/*.{ts,tsx}'],
outDir: 'dist/client',
format: ['esm'],
platform: 'browser',
splitting: true,
outExtension: () => ({ js: '.js' }),
...bundleless(),
},
{
...commonConfig(option),
entry: ['./src/client/index.ts'],
outDir: 'dist/client',
format: ['cjs'],
platform: 'neutral',
splitting: false,
outExtension: () => ({ js: '.cjs' }),
},
{
...commonConfig(option),
entry: {
index: 'src/node/index.ts',
},
platform: 'node',
target: 'node16',
noExternal: ['find-up'],
format: ['cjs'],
},
{
...commonConfig(option),
entry: {
index: 'src/node/index.ts',
},
platform: 'node',
target: 'node16',
format: ['esm'],
},
])