-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
114 lines (97 loc) · 2.09 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import { nodeResolve } from '@rollup/plugin-node-resolve';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import typescript from 'rollup-plugin-ts';
import commonjs from '@rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
import path from 'path';
import pkg from './package.json';
const commonOutputOptions = {
};
function getOutputOptions(options) {
return {
...commonOutputOptions,
...options,
};
}
function getCJSOutputOptions(options) {
return {
...getOutputOptions({
dir: 'lib/cjs',
...options,
}),
format: 'cjs',
exports: 'named',
};
}
function getESMOutputOptions(options) {
return {
...getOutputOptions({
dir: 'lib/esm',
...options,
}),
format: 'esm',
};
}
export default [
{
input: 'src/index.tsx',
output: [
// ESM
getESMOutputOptions({}),
// CommonJS
getCJSOutputOptions({})
],
plugins: [
peerDepsExternal(),
nodeResolve(),
commonjs(),
typescript({
tsconfig: path.resolve('./tsconfig.json')
}),
postcss({
extract: 'style.css',
}),
copy({
targets: [
{ src: 'README.md', dest: 'lib' },
{ src: 'package.json', dest: 'lib' },
{ src: 'LICENSE', dest: 'lib' },
]
})
],
external: Object.keys(pkg.devDependencies),
},
{
input: 'src/Form/index.tsx',
output: [
// ESM
getESMOutputOptions({
dir: 'lib/esm/form',
}),
// CommonJS
getCJSOutputOptions({
dir: 'lib/cjs/form',
})
],
plugins: [
peerDepsExternal(),
nodeResolve(),
commonjs(),
typescript({
tsconfig: path.resolve('./tsconfig.json')
}),
postcss({
extract: 'style.css',
}),
copy({
targets: [
{ src: 'README.md', dest: 'lib' },
{ src: 'package.json', dest: 'lib' },
{ src: 'LICENSE', dest: 'lib' },
]
})
],
external: Object.keys(pkg.devDependencies),
}
];