-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgatsby-node.js
More file actions
58 lines (53 loc) · 1.74 KB
/
gatsby-node.js
File metadata and controls
58 lines (53 loc) · 1.74 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
55
56
57
58
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.com/docs/node-apis/
*/
const fs = require("fs")
// MEME(PARK):"yarn develop"할떄, 사용
// exports.onCreateWebpackConfig = ({ stage, actions, getConfig }) => {
// actions.setWebpackConfig({
// externals: getConfig().externals.concat(function(context, request, callback) {
// const regex = /firebase(\/([\w\d]+))*/;
// // const regex = /^@?firebase(\/(.+))?/;
// if (regex.test(request)) {
// return callback(null, `umd ${request}`);
// }
// callback();
// }),
// });
// };
// MEME(PARK):"yarn deploy"할떄, 사용
exports.onCreateWebpackConfig = ({ stage, actions, getConfig }) => {
if (stage === 'build-html') {
actions.setWebpackConfig({
// Don't bundle modules that reference browser globals such as `window` and `IDBIndex` during SSR.
// See: https://github.com/gatsbyjs/gatsby/issues/17725
externals: getConfig().externals.concat(function(_context, request, callback) {
// Exclude bundling firebase* and react-firebase*
// These are instead required at runtime.
if (/^@?(react-)?firebase(.*)/.test(request)) {
console.log('Excluding bundling of: ' + request);
return callback(null, 'umd ' + request);
}
callback();
}),
});
}
};
exports.onPostBuild = () => {
fs.copyFile(`./firebase.json`, `./public/firebase.json`, err => {
if (err) {
throw err
}
})
}
exports.onCreatePage = ({ page, actions }) => {
const { createPage } = actions
// Make the front page match everything client side.
// Normally your paths should be a bit more judicious.
if (page.path === `/`) {
page.matchPath = `/*`
createPage(page)
}
}