-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathrollup.config.js
57 lines (54 loc) · 1.37 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
import path from 'path';
import nodeResolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs';
import { terser } from 'rollup-plugin-terser'
import pkg from './package.json'
import * as ReactIs from 'react-is';
const camelCase = string => {
const [first, ...rest] = string.split('-').map(str => str.toLowerCase());
return first + rest.map(str => str[0].toUpperCase() + str.slice(1)).join('')
};
const input = 'src/index.js';
const name = camelCase(pkg.name);
const external = id => !id.startsWith('.') && !path.isAbsolute(id);
const commonjsOptions = {
namedExports: {
'react-is': Object.keys(ReactIs)
}
}
export default [
{
input,
output: { file: pkg.main, format: 'cjs' },
external,
plugins: [
babel({ exclude: /node_modules/ }),
]
},
{
input,
output: { file: `dist/${pkg.name}.js`, format: 'umd', name },
plugins: [
nodeResolve(),
babel({ exclude: /node_modules/ }),
commonjs(commonjsOptions)
]
},
{
input,
output: { file: `dist/${pkg.name}.min.js`, format: 'umd', name },
plugins: [
nodeResolve(),
babel({ exclude: /node_modules/ }),
commonjs(commonjsOptions),
terser({
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
},
})
]
}
]