-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
gatsby-node.js
42 lines (37 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
const path = require(`path`)
exports.onCreateBabelConfig = ({ actions }) => {
// rewrites import { get }from 'lodash' into import get from 'lodash/get';
actions.setBabelPlugin({
name: `@sigmacomputing/babel-plugin-lodash`,
})
}
exports.onCreateWebpackConfig = function onCreateWebpackConfig({
stage,
actions,
}) {
const objectAssignStub = path.join(__dirname, `polyfills/object-assign.js`)
const noOp = path.join(__dirname, `polyfills/no-op.js`)
const fetchStub = path.join(__dirname, `polyfills/fetch.js`)
const whatwgFetchStub = path.join(__dirname, `polyfills/whatwg-fetch.js`)
const alias = {
// These files are already polyfilled so these should return in a no-op
// Stub Package: object.assign & object-assign
"object.assign": objectAssignStub,
"object-assign$": objectAssignStub,
"@babel/runtime/helpers/extends.js$": objectAssignStub,
// Stub package: fetch
unfetch$: fetchStub,
"unfetch/polyfill$": noOp,
"isomorphic-unfetch$": fetchStub,
"isomorphic-fetch$": fetchStub,
"whatwg-fetch$": whatwgFetchStub,
}
if (stage === `build-javascript` || stage === `develop`) {
alias[`url-polyfill$`] = noOp
}
actions.setWebpackConfig({
resolve: {
alias,
},
})
}