【问题标题】:How to write correct way for multiple folders in Gulp?如何在 Gulp 中为多个文件夹编写正确的方法?
【发布时间】:2017-05-31 03:01:26
【问题描述】:

我有下一个结构。

    html5
     |_33
       |_2.2.0
         |_js
           |_file1.js
           |_file2.js
           |_file3.js
     |_22
       |_2.2.0
         |_js
           |_file1.js
           |_file2.js
           |_file3.js
     |_24
       |_2.2.0
         |_js
           |_file1.js
           |_file2.js
           |_file3.js
    html5prod
     |_33
       |_2.2.0
         |_js
           |_file1(minify).js
           |_file2(minify).js
           |_file3(minify).js

我想从文件夹 html5 中移动 html5prod 中的缩小文件。

如果是一个文件夹我可以写

gulp.task('scripts', function() {
   return gulp.src('./html5/**/*.js')
       .pipe(uglify())
       .pipe(concat('min.js', {newLine: ';'}))
       .pipe(gulp.dest('./html5prod/24/2.2.0/js'));
});

如何为这个字符串中的所有文件夹写入目的地?

.pipe(gulp.dest('./html5prod/24/2.2.0/js'));

结果将是下一个, 从文件夹 html5 > 24 进入 html5prod > 24, 从 html5 > 33 进入 html5prod > 33

【问题讨论】:

标签: javascript html gulp


【解决方案1】:

从 gulp docs here查看这个食谱

它获取所有文件夹并开始遍历文件夹并将生成的脚本定向到目标。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-15
    • 2021-10-21
    • 1970-01-01
    • 1970-01-01
    • 2021-10-06
    • 1970-01-01
    • 1970-01-01
    • 2021-09-22
    相关资源
    最近更新 更多