我在gulp.src功能,即使用正則表達式基於路徑,如何從gulp.dest函數訪問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'
產生這種一飲而盡任務的src路徑,因爲我的源文件都位於多個文件夾。
我的要求是我還需要將我的結果保存在相對於我的src的多個文件夾中。
即,假設我的吞嚥任務結果文件是'template.js'
。現在我想將這個結果保存在'app/client/pages/**/views/template.js'
我該怎麼做?
檢查[gulp-rename](https://github.com/hparra/gulp-rename)插件。 – raina77ow
更改filepath.dirname和filepath.basename由於某種奇怪的原因而沒有爲我完成這項工作。 – jackOfAll