forked from facebookexperimental/Recoil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
47 lines (45 loc) · 1.32 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
import nodeResolve from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import {terser} from 'rollup-plugin-terser';
const config = mode => ({
input: 'src/Recoil_index.js',
output: {
file: `dist/recoil.${mode}.js`,
format: 'cjs',
exports: 'named',
},
external: ['react', 'react-dom'],
plugins: [
babel({
presets: ['@babel/preset-react', '@babel/preset-flow'],
plugins: [
'babel-preset-fbjs/plugins/dev-expression',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-optional-chaining',
'@babel/transform-flow-strip-types',
],
babelHelpers: 'bundled',
}),
{
resolveId: source => {
if (source === 'React') {
return {id: 'react', external: true};
}
if (source === 'ReactDOM') {
return {id: 'react-dom', external: true};
}
return null;
},
},
nodeResolve(),
commonjs(),
replace({
'process.env.NODE_ENV': JSON.stringify(mode),
}),
mode === 'development' ? undefined : terser({mangle: false}),
],
});
export default [config('development'), config('production')];