Gulp dest()基于文件名的动态目标文件夹 [英] Gulp dest() dynamic destination folders based on file names
本文介绍了Gulp dest()基于文件名的动态目标文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想迭代所有src文件,并将每个文件移动到以文件名本身命名的文件夹中,例如。
I want to iterate over all the src files and move every file in a folder named with the file name itself, for example.
来自:
hello.js
omg.js
到:
hello/
hello.js
omg/
omg.js
我有这个任务:
gulp.src('/*.js')
.pipe(gulp.dest('/' + filename here.......));
我如何实现这一目标?
推荐答案
gulp.task('pack', function () {
return gulp.src('temp/**/*.js')
.pipe(uglify())
.pipe(rename(function (path) {
path.dirname += "/"+path.basename;
path.extname = ".min.js";
}))
.pipe(gulp.dest('./build'));
});
这篇关于Gulp dest()基于文件名的动态目标文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文