1. <legend id='5Hq9s'><style id='5Hq9s'><dir id='5Hq9s'><q id='5Hq9s'></q></dir></style></legend>
      <i id='5Hq9s'><tr id='5Hq9s'><dt id='5Hq9s'><q id='5Hq9s'><span id='5Hq9s'><b id='5Hq9s'><form id='5Hq9s'><ins id='5Hq9s'></ins><ul id='5Hq9s'></ul><sub id='5Hq9s'></sub></form><legend id='5Hq9s'></legend><bdo id='5Hq9s'><pre id='5Hq9s'><center id='5Hq9s'></center></pre></bdo></b><th id='5Hq9s'></th></span></q></dt></tr></i><div id='5Hq9s'><tfoot id='5Hq9s'></tfoot><dl id='5Hq9s'><fieldset id='5Hq9s'></fieldset></dl></div>
    2. <tfoot id='5Hq9s'></tfoot>

      <small id='5Hq9s'></small><noframes id='5Hq9s'>

        <bdo id='5Hq9s'></bdo><ul id='5Hq9s'></ul>

      Node.js/Gulp - 循环执行 Gulp 任务

      时间:2023-05-29

        <tfoot id='qxrrq'></tfoot>
          <bdo id='qxrrq'></bdo><ul id='qxrrq'></ul>

              1. <i id='qxrrq'><tr id='qxrrq'><dt id='qxrrq'><q id='qxrrq'><span id='qxrrq'><b id='qxrrq'><form id='qxrrq'><ins id='qxrrq'></ins><ul id='qxrrq'></ul><sub id='qxrrq'></sub></form><legend id='qxrrq'></legend><bdo id='qxrrq'><pre id='qxrrq'><center id='qxrrq'></center></pre></bdo></b><th id='qxrrq'></th></span></q></dt></tr></i><div id='qxrrq'><tfoot id='qxrrq'></tfoot><dl id='qxrrq'><fieldset id='qxrrq'></fieldset></dl></div>

                <small id='qxrrq'></small><noframes id='qxrrq'>

              2. <legend id='qxrrq'><style id='qxrrq'><dir id='qxrrq'><q id='qxrrq'></q></dir></style></legend>
                  <tbody id='qxrrq'></tbody>
              3. 本文介绍了Node.js/Gulp - 循环执行 Gulp 任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我想遍历一个对象,并在每次迭代时将一组文件路径传递给 gulp.src,然后对这些文件进行一些处理.下面的代码仅用于说明目的,实际上并不能正常工作,因为 return 语句在第一遍就终止了循环.

                I'd like to loop through an object and pass an array of file paths to gulp.src on each iteration and then do some processing on those files. The code below is for illustration purposes and won't actually work since the return statement kills the loop on the first pass.

                gulp.task('js', function(){
                    for (var key in buildConfig.bundle) {
                        return gulp.src(bundleConfig.bundle[key].scripts)
                            .pipe(concat(key + '.js'));
                            // DO STUFF
                    }
                });
                

                这是基本的想法.关于如何做到这一点的任何想法?

                That's the basic idea. Any ideas on how to do this?

                推荐答案

                我能够使用合并流解决这个问题.如果有人有兴趣,这里是代码.这个想法是在循环中创建一个流数组,并在完成迭代时合并它们:

                I was able to pull this off using merge-streams. If anyone's interested, here's the code. The idea is to create an array of streams inside your loop and merge them when finished iterating:

                var merge = require('merge-stream');
                
                gulp.task('js', function(){
                
                    // Init vars
                    var jsBundleStreams = [];
                    var i = 0;
                
                    // Create array of individual bundle streams
                    for (var key in buildConfig.bundle) {
                        jsBundleStreams[i] = gulp.src(bundleConfig.bundle[key].scripts)
                            .pipe(concat(key + '.js'))
                            .pipe(gulp.dest('./public/papasteftest/'));
                        i++;
                    }
                
                    // Merge and return streams
                    return merge.apply(this, jsBundleStreams);
                
                });
                

                这篇关于Node.js/Gulp - 循环执行 Gulp 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:在完成函数本身的所有操作之前,Node 是否可以从 下一篇:使用 Browserify 和 Gulp 使用共享的公共库创建单独

                相关文章

                最新文章

                1. <tfoot id='iIcpI'></tfoot>

                    <small id='iIcpI'></small><noframes id='iIcpI'>

                    <i id='iIcpI'><tr id='iIcpI'><dt id='iIcpI'><q id='iIcpI'><span id='iIcpI'><b id='iIcpI'><form id='iIcpI'><ins id='iIcpI'></ins><ul id='iIcpI'></ul><sub id='iIcpI'></sub></form><legend id='iIcpI'></legend><bdo id='iIcpI'><pre id='iIcpI'><center id='iIcpI'></center></pre></bdo></b><th id='iIcpI'></th></span></q></dt></tr></i><div id='iIcpI'><tfoot id='iIcpI'></tfoot><dl id='iIcpI'><fieldset id='iIcpI'></fieldset></dl></div>
                    <legend id='iIcpI'><style id='iIcpI'><dir id='iIcpI'><q id='iIcpI'></q></dir></style></legend>

                      <bdo id='iIcpI'></bdo><ul id='iIcpI'></ul>