forked from pmndrs/react-spring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
68 lines (63 loc) · 1.98 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
import path from 'path'
import babel from 'rollup-plugin-babel'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import { uglify } from 'rollup-plugin-uglify'
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'
const root = process.platform === 'win32' ? path.resolve('/') : '/'
const external = id => !id.startsWith('.') && !id.startsWith(root)
const globals = {
react: 'React',
'react-dom': 'ReactDOM',
'prop-types': 'PropTypes',
'react-spring': 'ReactSpring',
}
const getBabelOptions = ({ useESModules }) => ({
exclude: '**/node_modules/**',
runtimeHelpers: true,
plugins: [['@babel/transform-runtime', { regenerator: false, useESModules }]],
})
function createConfig(entry, out, name) {
return [
{
input: `./src/${entry}.js`,
output: { file: `dist/${out}.js`, format: 'esm' },
external,
plugins: [babel(getBabelOptions({ useESModules: true })), sizeSnapshot()],
},
{
input: `./src/${entry}.js`,
output: { file: `dist/${out}.cjs.js`, format: 'cjs' },
external,
plugins: [babel(getBabelOptions({ useESModules: false }))],
},
...(name
? [
{
input: `./src/${entry}.js`,
output: {
file: `dist/${out}.umd.js`,
format: 'umd',
name,
globals,
},
external: Object.keys(globals),
plugins: [
resolve(),
babel(getBabelOptions({ useESModules: true })),
commonjs({ include: '**/node_modules/**' }),
sizeSnapshot(),
uglify(),
],
},
]
: []),
]
}
export default [
...createConfig('addons/index', 'addons', 'ReactSpringAddons'),
...createConfig('targets/web/index', 'web', 'ReactSpring'),
...createConfig('targets/native/index', 'native'),
...createConfig('targets/universal/index', 'universal'),
...createConfig('targets/konva/index', 'konva'),
]