如果我通过CLI使用webpack
,我可以导出配置数组:
module.exports = [
{
entry: {/*entry#1*/},
target: 'electron-renderer'
//...
},
{
entry: {/*entry#2*/}
target: 'webworker'
//...
}
];
它工作正常。但是当我尝试通过webpack-stream
中的gulpfile.js
传递它时
const webpackStream = require('webpack-stream');
const webpack2 = require('webpack');
const webpackConf = require('./webpack.config.js');
...
gulp.task('run webpack', () => {
return gulp.src('src/app.js') // I use only entry#1 here, cause it should override it via config file... I suppose
.pipe(webpackStream(webpackConf, webpack2))
.pipe(gulp.dest('dest/app'));
});
它完成任务没有错误,但从不将结果文件插入输出文件夹。
如果我写webpackStream(webpackConf[0], webpack2)
或webpackStream(webpackConf[1], webpack2)
(只有我的一个配置),它的效果会很好。
答案 0 :(得分:0)
您要找的是webpack-stream
的{{3}}。
您甚至不需要gulp.src
来自您的webpack配置的第一个条目,并且可以执行以下操作:
const webpackStream = require('webpack-stream');
const webpack2 = require('webpack');
const webpackConf = require('./webpack.config.js');
gulp.task('run webpack', () => {
return webpackStream({config: webpackConf}, webpack2)
.pipe(gulp.dest('dest/app'));
});