Skip to content

How to make the whole gulp abort when webpack has an error? #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pksjce opened this issue Sep 7, 2016 · 4 comments
Closed

How to make the whole gulp abort when webpack has an error? #104

pksjce opened this issue Sep 7, 2016 · 4 comments
Labels

Comments

@pksjce
Copy link

pksjce commented Sep 7, 2016

From @binarykitchen on February 17, 2015 21:11

Hello guys

I have the gulp (pseudo)code below. But when an error occurs, i.E. a module couldn't be found due to a wrong path, then the error is shown on gulp BUT the gulp task continues.

What change is required to make the gulp task stop?

Thanks!

var webpackCompiler = webpack({
     ...
  },
  plugins: _.compact([
    ...
});

gulp.task('webpack', function(cb) {
  return webpackCompiler.run(function(err, stats) {
    if (err) {
      throw new gutil.PluginError('webpack', err);
    }
    gutil.log("[webpack]", stats.toString({
      ...
    }));
    return cb();
  });
});

Copied from original issue: webpack/webpack#797

@pksjce
Copy link
Author

pksjce commented Sep 7, 2016

From @sirlancelot on February 18, 2015 7:33

Pass err in to cb

gulp.task('webpack', function(cb) {
  return webpackCompiler.run(function(err, stats) {
    if (err) return cb(err);
    gutil.log("[webpack]", stats.toString({
      ...
    }));
    return cb();
  });
});

@pksjce
Copy link
Author

pksjce commented Sep 7, 2016

From @binarykitchen on February 18, 2015 20:56

Oh right, thanks man! You might want to add that to the documentation. Because I believe this is better behavior than throw new gutil.PluginError('webpack', err);?

@pksjce
Copy link
Author

pksjce commented Sep 7, 2016

From @jhnns on February 18, 2015 23:58

Go ahead, the documentation is editable for everyone :)

@SpaceK33z
Copy link
Member

In #53 usage with Gulp will be documented.

hzuhyb pushed a commit to hzuhyb/webpack.js.org that referenced this issue Feb 18, 2017
bundle-loader and code-splitting-require
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants