-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-node.js
96 lines (84 loc) · 2.32 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
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
const PAGE_UTILS = require(`./src/build-utils/pages`);
const processPage = ({ pageQuery, createFunction, createPage }) => {
const promises = [];
promises.push(
new Promise((resolve, reject) => {
pageQuery
.then((result) => {
createFunction(result, createPage);
resolve();
})
.catch((error) => {
console.error(error);
reject(error);
});
})
);
return Promise.all(promises);
};
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions;
const promises = [];
// Process Home Pages
promises.push(
processPage({
pageQuery: PAGE_UTILS.homePage.query(graphql),
createFunction: PAGE_UTILS.homePage.createHomePages,
createPage,
})
);
// Process Help Pages
promises.push(
processPage({
pageQuery: PAGE_UTILS.helpPage.query(graphql),
createFunction: PAGE_UTILS.helpPage.createHelpPages,
createPage,
})
);
// Process Organisation Pages
promises.push(
processPage({
pageQuery: PAGE_UTILS.organisationPage.query(graphql),
createFunction: PAGE_UTILS.organisationPage.createOrganisationPages,
createPage,
})
);
// Process Modular Pages
promises.push(
processPage({
pageQuery: PAGE_UTILS.modularPage.query(graphql),
createFunction: PAGE_UTILS.modularPage.createModularPages,
createPage,
})
);
// Process FAQ Index Pages
promises.push(
processPage({
pageQuery: PAGE_UTILS.faqIndexPage.query(graphql),
createFunction: PAGE_UTILS.faqIndexPage.createFaqIndexPages,
createPage,
})
);
// Process FAQ Pages
promises.push(
processPage({
pageQuery: PAGE_UTILS.faqPage.query(graphql),
createFunction: PAGE_UTILS.faqPage.createFaqPages,
createPage,
})
);
return Promise.all(promises);
};
exports.onCreateWebpackConfig = ({ stage, actions, getConfig }) => {
// https://stackoverflow.com/a/63128321/20346883
if (stage === `develop` || stage === `build-javascript`) {
const config = getConfig();
const miniCssExtractPlugin = config.plugins.find(
(plugin) => plugin.constructor.name === `MiniCssExtractPlugin`
);
if (miniCssExtractPlugin) {
miniCssExtractPlugin.options.ignoreOrder = true;
}
actions.replaceWebpackConfig(config);
}
};