generated from egoist/ts-lib-starter
/
config.ts
107 lines (99 loc) · 2.07 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { Plugin as EsbuildPlugin, BuildOptions } from 'esbuild'
export const defineConfig = (
/**
* Multiple configurations = multiple builds
*/
config: Config | Config[],
) => config
export type Config = InputOptions & {
/**
* You can also supply multiple output configurations
*/
output: OutputOptions | OutputOptions[]
}
export type InputOptions = {
/**
* The context directory
*
* @default `process.cwd()`
*/
context?: string
/**
* Input files
*/
input?: string | string[] | Record<string, string>
plugins?: Plugin[]
esbuildPlugins?: EsbuildPlugin[]
/**
* Mark modules as external
*
* TODO: mark nesting module as external too,
* e.g. `external: ['preact']` should also mark `preact/compat` as external.
*/
external?: string[]
watch?: boolean
/**
* @see https://esbuild.github.io/api/#inject
*/
inject?: string[]
/**
* Allow JSX without importing `react`
*/
reactShim?: boolean
}
export type OutputOptions = {
dir?: string
format?: 'cjs' | 'esm' | 'iife' | 'dts'
/**
* Global name for IIFE module
*/
globalName?: string
/**
* Code splitting, for `esm` format only
*/
splitting?: boolean
minify?: boolean
banner?: {
js?: string
css?: string
}
footer?: {
js?: string
css?: string
}
legalComments?: BuildOptions['legalComments']
/**
* @see https://esbuild.github.io/api/#out-extension
*/
extension?: BuildOptions['outExtension']
/**
* @see https://esbuild.github.io/api/#pure
*/
pure?: string[]
/**
* The platform to run the bundled code
* @default `node`
*/
platform?: 'electron' | 'node'
}
type MaybePromise<T> = T | Promise<T>
/**
* yaup plugin, modeled after rollup plugin
*/
export type Plugin = {
name: string
/**
* Similar to rollup's `resolveId` hook
*/
resolveId?: (
id: string,
importer?: string,
) => MaybePromise<string | undefined | null | false>
/**
* Similar to rollup's `transform` hook
*/
transform?: (
code: string,
id: string,
) => MaybePromise<string | undefined | null>
}