-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docz-core): make onCreateWebpackConfig extendable
- Loading branch information
1 parent
3101e65
commit 8968a6c
Showing
1 changed file
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
const path = require('path') | ||
const get = require('lodash/get') | ||
|
||
exports.onCreateWebpackConfig = ({ actions }) => { | ||
actions.setWebpackConfig({ | ||
const NO_OP = () => {} | ||
|
||
let gatsbyNodeCustom | ||
try { | ||
gatsbyNodeCustom = require('./gatsby-node.custom') | ||
} catch (err) { | ||
gatsbyNodeCustom = { | ||
onCreateWebpackConfig: NO_OP, | ||
} | ||
} | ||
|
||
exports.onCreateWebpackConfig = args => { | ||
args.actions.setWebpackConfig({ | ||
resolve: { | ||
alias: { | ||
react: path.resolve('../node_modules/react'), | ||
}, | ||
}, | ||
}) | ||
const onCreateWebpackConfig = get( | ||
gatsbyNodeCustom, | ||
'onCreateWebpackConfig', | ||
NO_OP | ||
) | ||
onCreateWebpackConfig(args) | ||
} |