15

I am trying to update to webpack 2. I use webpack-stream to run stuff from gulp, but it appears that webpack-stream is using it's own dependency on webpack which is webpack 1.

I have not been able to find any webpack-stream with webpack 2. Is there any possibility to use webpack 2 from gulp?

Ilya Chernomordik
  • 27,817
  • 27
  • 121
  • 207

1 Answers1

38

You need to have both webpack and webpack-stream installed:

npm install --save-dev webpack-stream
npm install --save-dev webpack@2.1.0-beta.25

Then you can pass the webpack object as the second parameter to webpack-stream:

var gulp = require('gulp');
var webpackStream = require('webpack-stream');
var webpack2 = require('webpack');

gulp.task('default', function() {
  return gulp.src('src/entry.js')
    .pipe(webpackStream({/* options */}, webpack2))
    .pipe(gulp.dest('dist/'));
});
Sven Schoenung
  • 30,224
  • 8
  • 65
  • 70
  • That seems to do the trick, thanks a lot! Was really simple :) The errors are though in a bit different format – Ilya Chernomordik Nov 13 '16 at 14:44
  • Do you know maybe how to fix that as well? (I have red errors in separate line directly from node, but only console and a bit messed up new lines in gulp – Ilya Chernomordik Nov 13 '16 at 14:46
  • No idea, sorry. You might have to wait for a newer version of `webpack-stream`. Maybe file an issue on GitHub? – Sven Schoenung Nov 13 '16 at 15:56
  • It's not a critical thing, so I guess I'll live with it. Thanks a lot for help anyway :) – Ilya Chernomordik Nov 13 '16 at 16:31
  • Thanks @SvenSchoenung! I was missing that last argument into the webpackStream for using a different version of webpack. I've been stuck on this for hours. – Matt Goo Mar 01 '17 at 21:53
  • 3
    **Fair warning** webpack-stream has been abandoned for quite some time now and the [fork](https://www.npmjs.com/package/webpack-stream-fixed), while patching it some, doesn't solve the rest of the open issues on the original repo. – ZenMaster Mar 04 '17 at 05:11
  • 4
    For your information, there is a new version of webpack-stream for webpack2. You can find it [here](https://www.npmjs.com/package/webpack2-stream-watch). – Craig Stroman Mar 11 '17 at 23:14