Gulp dest() dynamic destination folders based on file names

旧巷老猫 提交于 2019-12-10 11:41:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!