-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
49 lines (46 loc) · 1.1 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
import { defineConfig, Options } from 'tsup';
import { umdWrapper } from 'esbuild-plugin-umd-wrapper';
import { version } from './package.json';
const clientName = 'capytable';
const baseConfig: Options = {
entry: {
['capytable']: 'src/capytable.ts',
},
outDir: 'dist',
outExtension({ format, options }) {
const ext = { esm: 'js', cjs: 'cjs', umd: 'umd.js' }[format];
const minExt = { esm: 'min.js', cjs: 'min.cjs', umd: 'umd.min.js' }[format];
const outputExtension = options.minify ? `${minExt}` : `${ext}`;
return {
js: `.${outputExtension}`,
};
},
platform: 'browser',
format: ['esm'],
name: clientName,
globalName: clientName,
bundle: true,
esbuildPlugins: [],
define: {
__VERSION__: `'${version}'`,
},
minify: true,
sourcemap: true,
dts: true,
clean: true,
esbuildOptions: (options) => {
options.legalComments = 'inline';
},
};
export default defineConfig([
{
...baseConfig,
esbuildPlugins: [],
},
{
...baseConfig,
// @ts-ignore
format: ['umd'],
esbuildPlugins: [umdWrapper({ external: 'inherit' })],
},
]);