diff --git a/lib/modules/pipeline/index.js b/lib/modules/pipeline/index.js index 2ff2592cc..c50f64772 100644 --- a/lib/modules/pipeline/index.js +++ b/lib/modules/pipeline/index.js @@ -86,20 +86,18 @@ class Pipeline { function shouldRunWebpack(next){ // assuming we got here because an asset was changed, let's check our webpack config // to see if the changed asset requires webpack to run - if(modifiedAssets || modifiedAssets.length) { - const configReader = new WebpackConfigReader({webpackConfigName: self.webpackConfigName}); - return configReader.readConfig((err, config) => { - if(err) return next(err); + if(!(modifiedAssets && modifiedAssets.length)) return next(null, false); + const configReader = new WebpackConfigReader({webpackConfigName: self.webpackConfigName}); + return configReader.readConfig((err, config) => { + if(err) return next(err); - if (typeof config !== 'object' || config === null) { - return next(__('bad webpack config, the resolved config was null or not an object')); - } + if (typeof config !== 'object' || config === null) { + return next(__('bad webpack config, the resolved config was null or not an object')); + } - const shouldRun = modifiedAssets.some(modifiedAsset => config.module.rules.some(rule => rule.test.test(modifiedAsset))); - return next(null, !shouldRun); - }); - } - next(null, false); + const shouldRun = modifiedAssets.some(modifiedAsset => config.module.rules.some(rule => rule.test.test(modifiedAsset))); + return next(null, !shouldRun); + }); }, function runWebpack(shouldNotRun, next) { if(shouldNotRun) return next();