Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass Webpack generated files to Gulp streams

Considering the following Webpack Gulp task, how can this be integrated with Gulp in such a way that after compiling Webpack pipes the files to Gulp so that I can run further tasks?

gulp.task('webpack', function(callback) {
  webpackCompiler.run(function(err, stats) {
    if (err) {
      throw new plugins.util.PluginError('webpack', err);
    }
    plugins.util.log('webpack', stats.toString({
      colors: true,
    }));
    callback();
  });
});

gulp.task('set-env-dev', function() {
  webpackConfig.plugins = [
    new webpack.BannerPlugin(info.name + '\n' + info.version + ':' + Date.now() + ' [development build]'),
    new ComponentPlugin()
  ];
  webpackCompiler = webpack( webpackConfig );
});
like image 866
Luis Martins Avatar asked Jun 20 '14 08:06

Luis Martins


People also ask

Can I use Webpack with Gulp?

In fact, webpack is a module binder, whereas gulp. js is a task runner -- this very definition implies that we can use both of the tools in assonance with each other with little to no conflict. But owing to webpack's wide array of features, many developers use webpack as a replacement for gulp.

Are Gulp and Webpack the same?

Webpack is a bundler whereas Gulp is a task runner, so you'd expect to see these two tools commonly used together. Instead, there's a growing trend, especially among the React community, to use Webpack instead of Gulp.

What is grunt and Gulp?

Both tools are task runners that use Node. js, which is an open source JavaScript runtime environment used to develop tools and applications. Grunt and Gulp both also use plugins to accomplish whatever tasks you need them to automate for you. Both tools use . js files to build tasks; for Grunt, you use a gruntfile.


1 Answers

There is now a plugin for Gulp that allows deeper integration of Webpack and Gulp: https://github.com/shama/webpack-stream

like image 108
Luis Martins Avatar answered Sep 22 '22 10:09

Luis Martins