【发布时间】:2015-12-28 12:57:41
【问题描述】:
我在 gulp.src 函数中使用基于正则表达式的路径,即,
gulp.task('gen-templateCache', function() {
return gulp.src('app/client/pages/**/views/**/markup/*.html')
.pipe(templateCache('new-templates.js'))
.pipe(gulp.dest(function(file){
//Access the src path
//Generate and Return the dest path based on the src path
}));
});
如您所见,我正在使用正则表达式 'app/client/pages/**/views/**/markup/*.html' 来生成此 gulp 任务的 src 路径,因为我的源文件位于多个文件夹中。
我的要求是我还需要将我的结果保存在相对于我的 src 的多个文件夹中。
即,假设我的 gulp 任务结果文件是 'template.js'。现在我想把这个结果保存在'app/client/pages/**/views/template.js'
我该怎么做?
【问题讨论】:
-
检查gulp-rename插件。
-
由于某些奇怪的原因,更改 filepath.dirname 和 filepath.basename 并没有为我做这项工作。