-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrollup.config.js
72 lines (62 loc) · 1.56 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
/* eslint-disable quote-props */
import typescript from 'rollup-plugin-typescript'
import commonjs from 'rollup-plugin-commonjs'
import resolve from 'rollup-plugin-node-resolve'
import babel from 'rollup-plugin-babel'
import * as react from 'react'
import * as reactDom from 'react-dom'
import * as reactIs from 'react-is'
import * as lodash from 'lodash'
const env = process.env.NODE_ENV
const isDevelopment = env === 'development'
const extensions = ['.js', '.jsx', '.ts', '.tsx']
export default {
input: './src/index.ts',
external: id => {
const list = [
'react',
'react-dom',
'lodash',
'redux',
'react-redux',
'redux-saga',
'reselect',
'immutability-helper-x',
'invariant',
'react-router-dom',
'regenerator-runtime/runtime'
]
if (list.includes(id) || /core-js/.test(id)) {
return true
}
return false
},
plugins: [
typescript(),
// Allows node_modules resolution
resolve({ extensions }),
// Allow bundling cjs modules. Rollup doesn't understand cjs
commonjs({
namedExports: {
react: Object.keys(react),
'react-dom': Object.keys(reactDom),
'react-is': Object.keys(reactIs),
lodash: Object.keys(lodash)
}
}),
// Compile TypeScript/JavaScript files
babel({ extensions, include: ['src/**/*'] })
],
output: [
{
file: isDevelopment
? 'dist/kop.dev.common.js'
: 'dist/kop.prod.common.js',
format: 'cjs'
},
{
file: 'dist/kop.esm.js',
format: 'es'
}
]
}