forked from iterative/dvc.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.js
43 lines (36 loc) · 1.54 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
require('dotenv').config()
global.__basedir = __dirname
const { setPageContext } = require('./src/gatsby/common')
const models = require('./src/gatsby/models.js')
const callOnModels = require('./src/gatsby/utils/models')
exports.createSchemaCustomization = api =>
callOnModels(models, 'createSchemaCustomization', api)
exports.sourceNodes = api => callOnModels(models, 'sourceNodes', api)
exports.onCreateNode = api => callOnModels(models, 'onCreateNode', api)
exports.createPages = api => callOnModels(models, 'createPages', api)
exports.createResolvers = api => callOnModels(models, 'createResolvers', api)
exports.onPostBuild = api => callOnModels(models, 'onPostBuild', api)
exports.onCreatePage = ({ page, actions }) => {
setPageContext(page, actions)
}
// Ignore warnings about CSS inclusion order, because we use CSS modules.
// https://spectrum.chat/gatsby-js/general/having-issue-related-to-chunk-commons-mini-css-extract-plugin~0ee9c456-a37e-472a-a1a0-cc36f8ae6033?m=MTU3MjYyNDQ5OTAyNQ==
exports.onCreateWebpackConfig = ({ stage, actions, getConfig }) => {
if (stage === 'build-javascript') {
const config = getConfig()
// Add polyfills
config.entry.app = [
'promise-polyfill/src/polyfill',
'isomorphic-fetch',
'raf-polyfill',
config.entry.app
]
const miniCssExtractPlugin = config.plugins.find(
plugin => plugin.constructor.name === 'MiniCssExtractPlugin'
)
if (miniCssExtractPlugin) {
miniCssExtractPlugin.options.ignoreOrder = true
}
actions.replaceWebpackConfig(config)
}
}