gpt4 book ai didi

javascript - Gulp dest() 基于文件名的动态目标文件夹

转载 作者:行者123 更新时间:2023-11-30 15:59:13 29 4
gpt4 key购买 nike

例如,我想遍历所有 src 文件并将每个文件移动到以文件名本身命名的文件夹中。

来自:

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'));
});

关于javascript - Gulp dest() 基于文件名的动态目标文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38025871/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com