-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrollup.config.ts
87 lines (85 loc) · 2.07 KB
/
rollup.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import typescript from '@rollup/plugin-typescript'
import json from '@rollup/plugin-json'
import terser from '@rollup/plugin-terser'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import del from 'rollup-plugin-delete'
import dts from 'rollup-plugin-dts'
import postcss from 'rollup-plugin-postcss'
import { plugin } from 'postcss'
import path from 'path'
// Remove Darkmode styles
const removeDark = plugin('remove-dark', () => {
return (root) => {
root.walkAtRules('media', rule => {
if (rule.params.includes('prefers-color-scheme:')) {
rule.remove()
}
})
}
})
export default [
{
input: './src/ui/index.ts',
output: [
{
intro: "'use client';",
file: './dist/ui/cjs/index.js',
format: 'cjs',
sourcemap: true,
globals: { react: 'React', mermaid: 'mermaid', prismjs: 'Prism' },
},
{
intro: "'use client';",
file: './dist/ui/esm/index.js',
format: 'esm',
sourcemap: true,
globals: { react: 'React', mermaid: 'mermaid', prismjs: 'Prism' },
},
{
intro: "'use client';",
file: './dist/ui/umd/index.js',
format: 'umd',
name: 'NotionateUI',
sourcemap: true,
globals: { react: 'React', mermaid: 'mermaid', prismjs: 'Prism' },
},
],
plugins: [
del({ targets: './dist/ui/*' }),
peerDepsExternal(),
resolve(),
json(),
commonjs(),
typescript(),
terser(),
postcss({
extract: true,
minimize: true,
}),
],
external: [
'react',
'react-dom',
'prismjs',
'mermaid',
'pdfjs-dist',
],
},
{
input: './src/ui/index.ts',
output: [{
file: './dist/ui/types.d.ts',
format: 'esm',
}],
plugins: [
dts(),
postcss({
extract: path.resolve('dist/ui/style-without-dark.css'),
minimize: true,
plugins: [removeDark],
}),
],
},
]