-
-
Notifications
You must be signed in to change notification settings - Fork 702
/
tsup.config.ts
62 lines (56 loc) · 1.26 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
61
62
import { defineConfig, Options } from 'tsup';
const injectFunc = `
function injectStyle(css) {
if (!css || typeof document === 'undefined') return
const head = document.head || document.getElementsByTagName('head')[0]
const style = document.createElement('style')
style.type = 'text/css'
if(head.firstChild) {
head.insertBefore(style, head.firstChild)
} else {
head.appendChild(style)
}
if(style.styleSheet) {
style.styleSheet.cssText = css
} else {
style.appendChild(document.createTextNode(css))
}
}
`;
const baseConfig: Options = {
minify: true,
target: 'es2018',
sourcemap: true,
dts: true,
format: ['esm', 'cjs'],
injectStyle: css => {
return `${injectFunc}injectStyle(${css});`;
},
banner: {
js: '"use client";'
}
};
export default defineConfig([
{
...baseConfig,
entry: ['src/index.ts'],
external: ['react'],
clean: ['dist']
},
{
...baseConfig,
injectStyle: false,
entry: { unstyled: 'src/index.ts' },
external: ['react'],
clean: ['dist']
},
{
...baseConfig,
entry: {
'use-notification-center/index': 'src/addons/use-notification-center/index.ts'
},
external: ['react', 'react-toastify'],
clean: ['addons'],
outDir: 'addons'
}
]);