forked from apollographql/react-apollo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
93 lines (88 loc) · 1.93 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import node from 'rollup-plugin-node-resolve';
import { uglify } from 'rollup-plugin-uglify';
import typescript from 'typescript';
import typescriptPlugin from 'rollup-plugin-typescript2';
import filesize from 'rollup-plugin-filesize';
import invariantPlugin from 'rollup-plugin-invariant';
function onwarn(message) {
const suppressed = ['UNRESOLVED_IMPORT', 'THIS_IS_UNDEFINED'];
if (!suppressed.find(code => message.code === code)) {
return console.warn(message.message);
}
}
const globals = {
'apollo-client': 'apollo.core',
'hoist-non-react-statics': 'hoistNonReactStatics',
'prop-types': 'propTypes',
'react': 'react',
'ts-invariant': 'invariant',
'tslib': 'tslib',
'lodash.isequal': 'isEqual',
};
function external(id) {
return Object.prototype.hasOwnProperty.call(globals, id);
}
export default [
{
input: 'src/index.ts',
output: {
file: 'lib/react-apollo.esm.js',
format: 'esm',
sourcemap: true,
globals,
},
external,
plugins: [
node({ module: true }),
typescriptPlugin({ typescript }),
invariantPlugin(),
filesize(),
],
onwarn,
},
{
input: 'lib/react-apollo.esm.js',
output: {
file: 'lib/react-apollo.cjs.js',
format: 'cjs',
name: 'react-apollo',
globals,
},
external,
onwarn,
},
{
input: 'lib/react-apollo.esm.js',
output: {
file: 'lib/react-apollo.umd.js',
format: 'umd',
name: 'react-apollo',
globals,
},
external,
onwarn,
},
{
input: 'lib/react-apollo.esm.js',
output: {
file: 'dist/bundlesize.js',
format: 'cjs',
name: 'react-apollo',
globals,
},
external,
plugins: [
uglify({
mangle: {
toplevel: true,
},
compress: {
global_defs: {
"@process.env.NODE_ENV": JSON.stringify("production"),
},
}
}),
],
onwarn,
},
];