-
Notifications
You must be signed in to change notification settings - Fork 6
/
rollup.config.js
95 lines (91 loc) · 1.88 KB
/
rollup.config.js
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
88
89
90
91
92
93
94
95
import { defineConfig } from 'rollup'
import nodeResolve from "@rollup/plugin-node-resolve";
import babel from "@rollup/plugin-babel";
import commonjs from "@rollup/plugin-commonjs";
import dts from 'rollup-plugin-dts';
import pkg from './package.json';
import { DEFAULT_EXTENSIONS } from '@babel/core'
import { minify } from 'rollup-plugin-esbuild'
const extensions = [...DEFAULT_EXTENSIONS, '.ts', '.tsx'];
function defaultPlugins(additionalPlugins = []) {
return [
nodeResolve({
extensions: ['.ts'],
}),
commonjs(),
process.env.NODE_ENV === 'production' && minify(),
...additionalPlugins
]
}
function defaultOutput(filename, additionalPlugins = []) {
return [
{
file: `dist/cjs/${filename}.js`,
format: 'cjs',
},
{
file: `dist/esm/${filename}.js`,
format: 'esm',
}
]
}
export default defineConfig([
{
input: 'src/index.tsx',
external: [
...Object.keys(pkg.peerDependencies),
'react/jsx-runtime'
],
output: defaultOutput(
'index',
),
plugins: defaultPlugins(
[
babel({
presets: [
"@babel/preset-typescript",
["@babel/preset-react", { "runtime": "automatic" }]
],
extensions
})
]
)
},
{
input: 'src/solid.tsx',
external: [
...Object.keys(pkg.peerDependencies),
'solid-js/web',
],
output: defaultOutput('solid'),
plugins: defaultPlugins([
babel({
presets: [
'@babel/preset-typescript',
'babel-preset-solid'
],
extensions
})
])
},
{
input: 'src/index.tsx',
output: {
file: 'dist/index.d.ts',
format: 'esm'
},
plugins: [
dts()
]
},
{
input: 'src/solid.tsx',
output: {
file: 'dist/solid.d.ts',
format: 'esm'
},
plugins: [
dts()
]
},
])