Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using webpack 2 from gulp (webpack-stream for webpack 2)?

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?

like image 604
Ilya Chernomordik Avatar asked Nov 13 '16 11:11

Ilya Chernomordik


People also ask

Is Webpack a task runner?

Webpack is a module bundler like Browserify or Brunch. It is not a task runner like Make, Grunt, or Gulp. Task runners handle automation of common development tasks such as linting, building, or testing your project. Compared to bundlers, task runners have a higher level focus.


1 Answers

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

npm install --save-dev webpack-stream
npm install --save-dev [email protected]

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/'));
});
like image 94
Sven Schoenung Avatar answered Oct 02 '22 08:10

Sven Schoenung