-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
rollup.config.js
121 lines (118 loc) · 2.67 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import resolve from "@rollup/plugin-node-resolve"
import babel from "@rollup/plugin-babel"
import commonjs from "@rollup/plugin-commonjs"
import json from "@rollup/plugin-json"
import replace from "@rollup/plugin-replace"
import autoExternal from "rollup-plugin-auto-external"
import internal from "rollup-plugin-internal"
import path from "path"
// Rollup hoists Ink's dynamic require of react-devtools-core which causes
// a window not found error so we exclude Ink's devtools file for now.
function excludeDevTools() {
const re = /ink/
return {
name: "ignoreDevTools",
load(id) {
if (id.match(re)) {
if (path.parse(id).name === `devtools`) {
return { code: `` }
}
}
},
}
}
export default [
{
input: {
index: `src/index.js`,
"graphql-server/server": `src/graphql-server/server.js`,
},
output: {
dir: `dist`,
entryFileNames: `[name].js`,
format: "cjs",
sourcemap: true,
},
plugins: [
replace({
values: {
"process.env.NODE_ENV": JSON.stringify(`production`),
},
}),
excludeDevTools(),
json(),
babel({
babelHelpers: `bundled`,
skipPreflightCheck: true,
exclude: `node_modules/**`,
}),
commonjs({
transformMixedEsModules: true,
}),
resolve({
dedupe: [
`react`,
`ink`,
`ink-select-input`,
`ink-spinner`,
`terminal-link`,
`react-reconcilier`,
`@mdx-js/mdx`,
`@mdx-js/react`,
`@mdx-js/runtime`,
`urql`,
`@urql/core`,
`subscriptions-transport-ws`,
],
}),
autoExternal(),
internal([
`react`,
`ink`,
`ink-select-input`,
`ink-spinner`,
`terminal-link`,
`react-reconcilier`,
`@mdx-js/mdx`,
`@mdx-js/react`,
`@mdx-js/runtime`,
`urql`,
`@urql/core`,
`subscriptions-transport-ws`,
]),
],
external: [
`ws`,
`gatsby-telemetry`,
`gatsby-core-utils`,
`yoga-layout-prebuilt`,
],
},
{
input: {
components: `src/components.js`,
},
output: {
dir: `dist/web/`,
entryFileNames: `[name].js`,
format: "es",
sourcemap: true,
},
plugins: [
babel({
babelHelpers: `bundled`,
skipPreflightCheck: true,
exclude: `node_modules/**`,
}),
commonjs({
transformMixedEsModules: true,
}),
resolve({
dedupe: [`@mdx-js/react`],
}),
autoExternal(),
internal([`@mdx-js/react`]),
],
external: [`react`],
},
]