-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrollup.config.mjs
131 lines (126 loc) · 2.76 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import terser from '@rollup/plugin-terser'
import typescript from '@rollup/plugin-typescript'
import url from '@rollup/plugin-url'
import svgr from '@svgr/rollup'
import copy from 'rollup-plugin-copy'
import del from 'rollup-plugin-delete'
import { dts } from 'rollup-plugin-dts'
import filesize from 'rollup-plugin-filesize'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import { visualizer } from 'rollup-plugin-visualizer'
import packageJson from './package.json' assert { type: 'json' }
const extensions = ['.ts', '.tsx']
const mainBundle = {
input: './src/index.ts',
output: [
{
file: packageJson.main,
exports: 'named',
interop: 'auto',
format: 'cjs',
sourcemap: true,
},
{
file: packageJson.module,
format: 'esm',
interop: 'auto',
sourcemap: true,
},
],
plugins: [
del({
targets: 'dist/*',
}),
peerDepsExternal(),
url(),
svgr(),
json(),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
exclude: [
'node_modules',
'dist',
'**/__test__/*',
'**/__mocks__/*',
'**/stories/*',
],
}),
copy({
targets: [
{
src: './src/tailwind.css',
dest: './dist',
},
],
}),
resolve(),
terser({ compress: { evaluate: false } }),
filesize(),
visualizer(),
],
}
const iconBundle = {
input: './src/components/icons/index.ts',
output: [
{
file: 'dist/ooni-components-icons.cjs.js',
exports: 'named',
interop: 'auto',
format: 'cjs',
sourcemap: true,
},
{
file: 'dist/ooni-components-icons.esm.js',
format: 'esm',
interop: 'auto',
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
url(),
svgr(),
json(),
resolve(),
commonjs({ transformMixedEsModules: true }),
typescript({
tsconfig: './icons/tsconfig.json',
exclude: ['**/__test__/*', '**/__mocks__/*', '**/stories/*'],
}),
terser(),
filesize(),
visualizer(),
],
}
const declarationGenerator = {
input: 'dist/types/src/index.d.ts',
output: [{ file: 'dist/index.d.ts', format: 'esm' }],
plugins: [
dts(),
del({
targets: './dist/types',
hook: 'buildEnd',
}),
],
}
const iconDeclarationGenerator = {
input: 'dist/icons/types/index.d.ts',
output: [{ file: 'dist/ooni-components-icons.d.ts', format: 'esm' }],
plugins: [
dts(),
del({
targets: './dist/icons',
hook: 'buildEnd',
}),
],
}
export default [
mainBundle,
declarationGenerator,
iconBundle,
iconDeclarationGenerator,
]