Return early if no modified assets

This commit is contained in:
emizzle 2018-10-19 16:03:56 +11:00 committed by Pascal Precht
parent 5b1a226885
commit 3437f80a89
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 10 additions and 12 deletions

View File

@ -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();