Skip to content

Commit

Permalink
fix(docz-core): make onCreateWebpackConfig extendable
Browse files Browse the repository at this point in the history
  • Loading branch information
rakannimer committed Sep 2, 2019
1 parent 3101e65 commit 8968a6c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions core/docz-core/templates/gatsby-node.tpl.js
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)
}

0 comments on commit 8968a6c

Please sign in to comment.