forked from pixijs/pixi-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
66 lines (61 loc) · 1.6 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
import commonjs from 'rollup-plugin-commonjs'
import filesize from 'rollup-plugin-filesize'
import resolve from 'rollup-plugin-node-resolve'
import { terser } from 'rollup-plugin-terser'
import json from 'rollup-plugin-json'
import babel from 'rollup-plugin-babel'
import replace from 'rollup-plugin-replace'
import globals from 'rollup-plugin-node-globals'
const prod = process.env.NODE_ENV === 'production'
function getConfig(dest, format) {
return {
input: 'src/index.js',
output: {
exports: 'named',
file: dest,
format,
name: 'ReactPixi',
sourcemap: !prod,
globals: {
'pixi.js': 'PIXI',
'react': 'React'
},
},
plugins: [
json(),
babel({ exclude: 'node_modules/**' }),
resolve({
browser: true,
mainFields: ['main', 'jsnext']
}),
commonjs({
ignoreGlobal: false,
namedExports: {
'node_modules/scheduler/index.js': [
'unstable_scheduleCallback',
'unstable_cancelCallback'
]
}
}),
replace({
__DEV__: prod ? 'false' : 'true',
'process.env.NODE_ENV': prod ? '"production"' : '"development"',
}),
globals(),
prod && terser(),
filesize(),
].filter(Boolean),
external: [
'pixi.js',
'react',
'react-dom'
]
}
}
const buildType = prod ? '' : '-dev'
const configs = [
getConfig(`dist/react-pixi.cjs${buildType}.js`, 'cjs'),
getConfig(`dist/react-pixi.umd${buildType}.js`, 'umd'),
getConfig(`dist/react-pixi.module${buildType}.js`, 'es'),
]
export default configs