Skip to content

Errors are not shown with gulp + webpack-stream #296

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

Open
NN--- opened this issue Mar 22, 2018 · 7 comments
Open

Errors are not shown with gulp + webpack-stream #296

NN--- opened this issue Mar 22, 2018 · 7 comments

Comments

@NN---
Copy link

NN--- commented Mar 22, 2018

If I run webpack with HardSourcePlugin through gulp using webpack-stream ( https://github.com/shama/webpack-stream) , I don't see any errors.
Just build failure.

Without HardSourcePlugin the errors are displayed properly.

@stereokai
Copy link

stereokai commented Mar 22, 2018

Maybe this will help you: webpack-stream didn't cut it for us for multiple reasons, including what you're talking about. Eventually, I wrote our own script to run webpack through gulp, like this:

gulp.task('build-webpack', done => {
  webpackAsync('webpack.config.js', done);
});
function webpackAsync (config, entry, callback) {
  config = require(path.join(configsLocation, config));

  webpack(config, (error, stats) => {
    if (hasErrors(stats)) {
      // Break Gulp execution:
      process.exit(1);

      // Or return the error to Gulp (you can choose)
      // if (typeof callback === 'function') {
      //   callback(new Error('Webpack error (see above).');
      // }
    } else if (typeof callback === 'function') {
      callback();
    }
  });
}

* We have multiple builds, hence requireing the build from within webpackAsync and not from the Gulp task.

@NN---
Copy link
Author

NN--- commented Mar 22, 2018

I’ll try this. Thanks.
Any reason you don’t return Promise?

@stereokai
Copy link

stereokai commented Mar 22, 2018

You mean like so?

gulp.task('build-webpack', () => {
  return webpackAsync('webpack.config.js'); // (considering webpackAsync return a promise of course)
});

@NN---
Copy link
Author

NN--- commented Mar 22, 2018

Yes, that way you don’t need done argument.
Btw instead of require you could also do it async with fse.read (fs-extra) or util.promisify.
It will make build faster ;)

@stereokai
Copy link

What do you mean will make build faster?

@NN---
Copy link
Author

NN--- commented Mar 22, 2018

Asynchronous operation allows other IO operation to be done at the same time.

@NN---
Copy link
Author

NN--- commented Mar 22, 2018

@stereokai Do you know how to make multiple output directories using your method ?
Currently I have:

gulp.src("*")
.pipe(webpackStream(require(webpackConfig), webpack))
.pipe(gulp.dest("out1"))
.pipe(gulp.dest("out2"))

I can do manually build + copy, but using gulp.dest is much nicer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants