-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.mjs
executable file
·103 lines (98 loc) · 2.03 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
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
import styles from '@ironkinoko/rollup-plugin-styles'
import json from '@rollup/plugin-json'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import terser from '@rollup/plugin-terser'
import typescript from '@rollup/plugin-typescript'
import url from '@rollup/plugin-url'
import dts from 'rollup-plugin-dts'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
const dist = 'dist'
const bundle = 'bundle'
const outputsCommon = {
sourcemap: true,
interop: 'compat'
}
const outputs = [
{
file: `${dist}/${bundle}.cjs.js`,
format: 'cjs',
//https://rollupjs.org/guide/en/#outputexports
exports: 'named',
...outputsCommon
},
{
file: `${dist}/${bundle}.esm.js`,
format: 'esm',
...outputsCommon
},
{
name: 'PurpleComponents',
file: `${dist}/${bundle}.umd.js`,
globals: {
react: 'React',
'styled-components': 'styled',
'react-select': 'Select',
'react-dropzone': 'reactDropzone',
'react-pdf': 'reactPdf'
// Must not be here, otherwise the library is not correctly loaded
// nanoid: 'nanoid'
},
format: 'umd',
...outputsCommon
}
]
const common = {
input: 'src/index.tsx',
external: [
'@react-hook/previous',
'@tippyjs/react',
'@tippyjs/react/headless',
'countries-and-timezones',
'lodash/intersection',
'lodash/pick',
'lodash/isEqual',
'nanoid',
'nouislider',
'is-mobile',
'react',
'react-day-picker',
'react-dropzone',
'react-inlinesvg',
'react-pdf',
'react-select',
'react-tabs',
'prop-types',
'styled-components',
'styled-system',
'formik',
'zxcvbn'
],
plugins: [
json(),
peerDepsExternal(),
typescript({
tsconfig: './tsconfig.json'
}),
url(),
styles(),
nodeResolve({
extensions: ['.css']
}),
terser()
]
}
export default outputs
.map((output) => ({
...common,
output
}))
.concat({
input: `${dist}/types/index.d.ts`,
output: [{ file: `${dist}/index.d.ts`, format: 'es' }],
plugins: [dts()],
external: [
'nouislider/dist/nouislider.css',
'tippy.js/dist/tippy.css',
'react-day-picker/dist/style.css'
]
})