Skip to content

Commit 58ea254

Browse files
committed
Add invariant for value returned when user modifies the Webpack config (#300)
Fixes #269
1 parent fed1503 commit 58ea254

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/utils/webpack.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Config from 'webpack-configurator'
55
const debug = require('debug')('gatsby:webpack-config')
66
import path from 'path'
77
import _ from 'lodash'
8+
import invariant from 'invariant'
89

910
import babelConfig from './babel-config'
1011

@@ -380,7 +381,14 @@ module.exports = (program, directory, stage, webpackPort = 1500, routes = []) =>
380381
})
381382

382383
if (modifyWebpackConfig) {
383-
return modifyWebpackConfig(module(config), stage)
384+
const modifiedWebpackConfig = modifyWebpackConfig(module(config), stage)
385+
invariant(_.isObject(modifiedWebpackConfig),
386+
`
387+
You must return an object when modifying the Webpack config.
388+
Returned: ${modifiedWebpackConfig}
389+
stage: ${stage}
390+
`)
391+
return modifiedWebpackConfig
384392
} else {
385393
return module(config)
386394
}

0 commit comments

Comments
 (0)