-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
65 lines (59 loc) · 1.68 KB
/
rollup.config.mjs
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
import commonjs from '@rollup/plugin-commonjs'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import typescript from '@rollup/plugin-typescript'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
const getConfig = input => {
const isSingle = input !== './index.ts'
return {
external: [
'ramda',
'remark-parse',
'remark-slate',
'sha1',
'slate',
'slate-history',
'slate-react',
'tslib',
'unified',
],
input,
output: [
isSingle
? {
file: './dist/fields/Select.js',
format: 'es',
preserveModules: false,
sourcemap: false,
}
: {
dir: './dist',
format: 'es',
preserveModules: true,
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
nodeResolve({
extensions: ['css', '.js', 'json', '.jsx', '.ts', '.tson', '.tsx', 'woff', 'woff2'],
ignoreSideEffectsForRoot: true,
}),
// Convert CommonJS to ES6:
commonjs(),
// Transpile TS & TSX to JS:
typescript({
tsconfig: isSingle ? './tsconfig.dist.single.json' : './tsconfig.dist.json',
}),
// Hack to make styled-component compatible with Next.js inability to fully support ESM:
replace({
'= styled(': '= (styled.default || styled)(',
'= styled.': '= (styled.default || styled).',
delimiters: ['', ''],
preventAssignment: false,
}),
],
}
}
// eslint-disable-next-line import/no-default-export
export default ['./index.ts', './fields/Select.tsx'].map(getConfig)