forked from brianzinn/react-babylonjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
39 lines (34 loc) · 1.06 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
import json from '@rollup/plugin-json';
import typescript from 'rollup-plugin-typescript2';
const pkg = require('./package.json')
const libraryName = pkg.name
const isProduction = process.env.NODE_ENV === 'production';
console.log('ENV:', process.env.NODE_ENV, libraryName)
const exportGlobals = {
'react': 'React',
'react-dom': 'ReactDom',
'react-reconciler': 'ReactReconciler',
'@babylonjs/core': 'BabylonjsCore'
}
export default (async () => {
const result = {
input: `src/${libraryName}.ts`,
output: [{
file: pkg.module,
format: 'es',
sourcemap: true,
globals: exportGlobals,
}],
context: 'window',
// external modules not in bundle (i.e.: 'react')
external: [...Object.keys(pkg.peerDependencies || {})],
plugins: [
json(),
typescript(),
// minimize production build
isProduction && (await import('rollup-plugin-terser')).terser()
]
}
// console.log(`rollup config:\n -> external \n${JSON.stringify(result.external)}\n ->${JSON.stringify(result.output)}`);
return result;
})