问题
I want to iterate over all the src files and move every file in a folder named with the file name itself, for example.
from:
hello.js
omg.js
to:
hello/
hello.js
omg/
omg.js
I have this task:
gulp.src('/*.js')
.pipe(gulp.dest('/' + filename here.......));
How do i achieve this?
回答1:
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'));
});
来源:https://stackoverflow.com/questions/38025871/gulp-dest-dynamic-destination-folders-based-on-file-names