-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtsup.config.ts
44 lines (41 loc) · 1.09 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
import fs from 'fs';
import { defineConfig } from 'tsup';
export default defineConfig((options) => {
if (!options.minify) {
fs.rmSync('./dist', { recursive: true, force: true });
}
const config = {
entry: options.minify
? {
'zmooth.min': 'src/index.ts',
}
: {
zmooth: 'src/index.ts',
},
clean: false,
dts: true,
sourcemap: options.watch,
bundling: !options.watch,
platform: 'browser',
outExtension({ format }) {
if (format === 'cjs') return { js: `.cjs` };
else if (format === 'esm') return { js: `.mjs` };
else if (format === 'iife') return { js: `.js` };
return { js: `.${format}.js` };
},
};
return [
{
...config,
format: ['cjs', 'esm'],
},
{
...config,
format: ['iife'],
globalName: 'zmooth',
footer: {
js: 'zmooth = zmooth.default;',
},
},
];
});