-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
46 lines (41 loc) · 1.06 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
import { defineConfig } from 'tsup'
import type { NormalizedOptions, Format } from 'tsup'
interface Context {
options: NormalizedOptions
format: Format
/** "type" field in project's package.json */
pkgType?: string
}
interface Result {
js?: string
}
function outputExtensions(ctx: Context): Result {
if (ctx.format === 'cjs') return { js: '.js' }
if (ctx.format === 'esm') return { js: '.mjs' }
return { js: '.min.js' }
}
// You can put license here.
// Example
const license = '/* This is Unlicensed */'
export default defineConfig({
splitting: false,
entry: ['src/index.ts'],
// Generate declaration file (.d.ts & .d.mts)
// And adds banner
dts: {
banner: license
},
// Builds for commonJS, ESmodules & Browser
format: ['cjs', 'esm', 'iife'],
outExtension: outputExtensions,
// Cleaning './dist/' before building
clean: true,
// Header/Banner
banner: {
js: license
},
// Minify Options
minifyIdentifiers: false,
minifySyntax: true,
minifyWhitespace: true
})