-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgatsby-node.js
43 lines (39 loc) · 1.23 KB
/
gatsby-node.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
exports.onCreateWebpackConfig = ({ stage, actions, getConfig }) => {
if (stage === 'build-html') {
actions.setWebpackConfig({
externals: getConfig().externals.concat(function (
context,
request,
callback
) {
const regex = /^@?firebase(\/(.+))?/;
// exclude firebase products from being bundled, so they will be loaded using require() at runtime.
if (regex.test(request)) {
return callback(null, 'umd ' + request);
}
callback();
})
});
}
};
// graphql function doesn't throw an error so we have to check to check for the result.errors to throw manually
const wrapper = (promise) =>
promise.then((result) => {
if (result.errors) {
throw result.errors;
}
return result;
});
const re = /^\/([\w-]+)\/me/;
exports.onCreatePage = async ({ page, actions }) => {
const { createPage } = actions;
const match = re.exec(page.path);
// Only update the `/me` page.
if (match) {
// page.matchPath is a special key that's used for matching pages
// with corresponding routes only on the client.
page.matchPath = `${match[0]}/*`;
// Update the page.
createPage(page);
}
};