我的 gulp 代码部分如下所示
gulp.src(['../application-base/**/**.js', '!../application-base/assets/**/**.js'], { base: './' })
.pipe(gulpPlumber({
errorHandler: function (error) {
console.log(`\nError ${error}`);
this.emit('end');
}
}))
.pipe(gprint(filePath => "Transpiling: " + filePath.replace('..\\application-base\\', '')))
.pipe(babel({ compact: false }))
.pipe(gulp.dest('../application-base-transpiled/'))
.on('end', () => done());
如果我改变
.pipe(gulp.dest('../application-base-transpiled/'))
to
.pipe(gulp.dest(''))
然后创建转译文件,并覆盖原始文件。问题是
.pipe(gulp.dest('../application-base-transpiled/'))
不保存文件,以相同的原始路径,在application-base-transpiled
正如你所看到的,我正在使用一个底座,但它似乎可以正常工作。
我缺少什么?
EDIT
我仔细观察了一下,似乎即使是
.pipe(gulp.dest('../application-base-transpiled/'))
Gulp 仍然将转译的文件放到原来的位置,覆盖原来的文件。 Gulp 不喜欢我所经过的目的地,并且默默地忽略了它。
EDIT 2
它似乎removing the base
选项解决了这个问题,这与我在其他地方看到的建议相反。的文档gulp.dest
不要真正讨论这个。
谁能对此提供一些见解?
EDIT 3
根据斯文的回答,我尝试过这个
gulp.src(['**/**.js', '!assets/**/**.js'], { base: '../application-base' })
.pipe(gulpPlumber({
errorHandler: function errorHandler(error) {
console.log('\nError ' + error);
this.emit('end');
}
}))
.pipe(gprint(filePath => "Transpiling: " + filePath.replace('..\\application-base\\', '')))
.pipe(babel({ compact: false }))
.pipe(gulp.dest('../application-base-transpiled/'))
.on('end', () => done());
但似乎基础被忽略了,我自己当前目录中的文件被抓取并就地转译(我最不想要的 - 幸运的是 GIT 有助于消除损坏)。
使用数组时是否忽略基本参数src
?