forked from jacques-blom/Recoil
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
54 lines (52 loc) · 1.54 KB
/
rollup.config.js
File metadata and controls
54 lines (52 loc) · 1.54 KB
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
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';
const config = ({mode, target}) => ({
input: 'src/Recoil.js',
output: {
file:
target === 'web'
? `dist/recoil.${mode}.js`
: `dist/recoil.${mode}.${target}.js`,
format: 'cjs',
exports: 'named',
},
external: ['react', 'react-dom', 'react-native'],
plugins: [
babel({
presets: ['@babel/preset-react', '@babel/preset-flow'],
plugins: [
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-class-properties',
],
babelHelpers: 'bundled',
}),
{
resolveId: source => {
if (source === 'React') {
return {id: 'react', external: true};
}
if (source === 'ReactDOM') {
return {id: 'react-dom', external: true};
}
if (source === 'ReactNative') {
return {id: 'react-native', external: true};
}
return null;
},
},
nodeResolve({
extensions: target === 'native' ? ['.native.js', '.js'] : undefined,
}),
commonjs(),
mode === 'development' ? undefined : terser({mangle: false}),
],
});
export default [
config({mode: 'development', target: 'web'}),
config({mode: 'production', target: 'web'}),
config({mode: 'development', target: 'native'}),
config({mode: 'production', target: 'native'}),
];