使用gulp的webpack 2(webpack-stream for webpack 2)?

时间:2016-11-13 11:16:42

标签: gulp webpack webpack-2

我正在尝试更新到webpack 2.我使用webpack-stream从gulp运行东西,但似乎webpack-stream正在使用它自己对webpack的依赖,这是webpack 1。

我无法在webpack 2中找到任何webpack-stream 2.是否有可能从gulp使用webpack 2?

1 个答案:

答案 0 :(得分:38)

您需要同时安装webpackwebpack-stream

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

然后,您可以将webpack对象作为第二个参数传递给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/'));
});