使用来自 gulp 的 webpack 2(webpack 2 的 webpack-stream)?

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

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

我没能找到任何带有 webpack 2 的 webpack-stream。有没有可能使用来自 gulp 的 webpack 2?

您需要同时安装 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/'));
});