-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
74 lines (71 loc) · 1.7 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
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import external from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import resolve from 'rollup-plugin-node-resolve';
import replace from 'rollup-plugin-replace';
import { uglify } from 'rollup-plugin-uglify';
import url from 'rollup-plugin-url';
import svgr from '@svgr/rollup';
const fs = require('fs');
const path = require('path');
const componentDir = 'src/components';
const cModuleNames = fs.readdirSync(path.resolve(componentDir));
const cModuleMap = cModuleNames.reduce((prev, name) => {
prev[name] = `${componentDir}/${name}/index.js`;
return prev;
}, {});
const plugins = [
external(),
postcss(),
url(),
svgr(),
babel({
exclude: 'node_modules/**',
plugins: ['@babel/plugin-external-helpers'],
}),
resolve(),
commonjs(),
];
export default [
{
input: {
index: 'src/index.js',
...cModuleMap,
},
output: [
{
dir: 'lib',
entryFileNames: '[name]/index.js',
format: 'cjs',
sourcemap: true,
},
{
dir: 'es',
entryFileNames: '[name]/index.js',
format: 'es',
sourcemap: true,
},
],
plugins,
experimentalCodeSplitting: true,
},
{
input: 'src/index.js',
output: {
format: 'umd',
file: 'umd/kabi.js',
name: 'kabi',
},
plugins: [...plugins, replace({ 'process.env.NODE_ENV': '"development"' })],
},
{
input: 'src/index.js',
output: {
format: 'umd',
file: 'umd/kabi.min.js',
name: 'kabi',
},
plugins: [...plugins, replace({ 'process.env.NODE_ENV': '"production"' }), uglify()],
},
];