-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
46 lines (44 loc) · 1.25 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
import fs from 'fs';
import path from 'path';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import resolve from 'rollup-plugin-node-resolve';
import svg from 'rollup-plugin-svg';
const config = fs
.readdirSync('src')
.filter(srcSubDir => ['components'].includes(srcSubDir))
.reduce(
(acc, dir) => [
...acc,
...fs.readdirSync(`src/${dir}`).map(filePath => path.join(`src/${dir}`, filePath))
],
[]
)
.map(component => ({
input: `${component}/index.js`,
plugins: [
peerDepsExternal(),
svg({
base64: true
}),
babel({
exclude: 'node_modules/**',
runtimeHelpers: true,
externalHelpers: true
}),
commonjs(),
resolve()
],
output: [
{
file: `packages/${component.split('/').pop()}.js`,
format: 'cjs'
},
{
file: `packages/es/${component.split('/').pop()}.js`,
format: 'esm'
}
]
}));
export default config;