-
Notifications
You must be signed in to change notification settings - Fork 3
/
tsup.config.ts
60 lines (53 loc) · 1.25 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
56
57
58
59
60
import type { Options } from 'tsup';
import { defineConfig } from 'tsup';
import { esbuildPluginVersionInjector } from 'esbuild-plugin-version-injector';
const opts: Options = {
name: "rita",
entry: { rita: 'src/rita.js' },
outDir: 'dist',
watch: false,
clean: true,
minify: false,
sourcemap: true,
dts: false,
bundle: true,
target: 'es2020',
metafile: false, // toggle for stats: https://esbuild.github.io/analyze/
esbuildPlugins: [esbuildPluginVersionInjector()],
outExtension({ format }) { return { js: `.js` } },
}
const esm: Options = {
format: ['esm'],
...opts,
}
const cjs: Options = {
format: ['cjs'],
...opts,
platform: "node",
cjsInterop: true,
splitting: true,
outExtension({ format }) { return { js: `.cjs` } },
}
const iife: Options = {
format: ['iife'],
...opts,
minify: true,
platform: "browser",
globalName: "iife",
footer: { js: "RiTa = iife.RiTa" },
outExtension({ format }) { return { js: `.min.js` } },
}
const testEsm: Options = {
format: ['esm'],
platform: "node",
name: "test",
entry: ['test/[^i]*.js'],
outDir: 'test/dist',
watch: false,
clean: false,
minify: false,
sourcemap: false,
dts: false,
bundle: false,
}
export default defineConfig([esm, cjs, iife, testEsm]);