• <small id='JxpW6'></small><noframes id='JxpW6'>

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

      • <bdo id='JxpW6'></bdo><ul id='JxpW6'></ul>
    1. <legend id='JxpW6'><style id='JxpW6'><dir id='JxpW6'><q id='JxpW6'></q></dir></style></legend><tfoot id='JxpW6'></tfoot>
      1. 如何在 gulp 中创建重复管道?

        时间:2023-05-28
          <tfoot id='VbM0m'></tfoot>

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

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

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

                  <tbody id='VbM0m'></tbody>

                <legend id='VbM0m'><style id='VbM0m'><dir id='VbM0m'><q id='VbM0m'></q></dir></style></legend>
                • 本文介绍了如何在 gulp 中创建重复管道?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个 gulp 任务在 index.html 中注入几个依赖项:

                  I have a gulp task to inject several dependencies in index.html as this :

                  return gulp.src(config.serve.html)
                            .pipe($.inject(gulp.src(prependSource(config.inject.source.indexes)), {
                              read: false,
                              starttag: config.inject.indexes,
                              addRootSlash: false,
                              addPrefix: prefix,
                              ignorePath: ignore
                            }))
                            .pipe($.inject(gulp.src(managerList), {
                              read: false,
                              starttag: config.inject.managers,
                              addRootSlash: false,
                              addPrefix: prefix,
                              ignorePath: ignore
                            }))
                            .pipe($.inject(gulp.src(prependSource(config.inject.source.directives)), {
                              read: false,
                              starttag: config.inject.directives,
                              addRootSlash: false,
                              addPrefix: prefix,
                              ignorePath: ignore
                            }))
                  
                            .pipe($.inject(gulp.src(prependSource(config.inject.source.routes)), {
                              read: false,
                              starttag: config.inject.routes,
                              addRootSlash: false,
                              addPrefix: prefix,
                              ignorePath: ignore
                            }))
                            .pipe($.inject(gulp.src(prependSource(config.inject.source.css)), {
                              read: false,
                              starttag: config.inject.css,
                              addRootSlash: false,
                              addPrefix: prefix,
                              ignorePath: ignore
                            }))
                  
                  
                            .pipe($.size())
                            .pipe(gulp.dest(dest));
                  };
                  

                  如您所见,所有管道都以某种方式重复(managerList 除外).所以我想要的是在一系列注入的帮助下将重复管道合并到一个管道中.如何达到同样的效果?

                  As you can see, all the pipes are in repeating in some fashion (except the managerList). So what I want is to consolidate the repeating pipes into one single pipe, with the help of an array of injects. How to achieve the same?

                  推荐答案

                  gulp.src 返回一个流(每个 .pipe 也是如此).如果您考虑每个 .pipe 调用在做什么,您可以简单地将其转换为 for 循环.像这样的:

                  gulp.src returns a stream (as does each .pipe). If you think about what each .pipe call is doing, you can simply turn it into a for loop. Something like this:

                  config = { /* your config object */ };
                  
                  var stream = gulp.src(/* source glob */);
                  for (var i = 0; i < injects.length; i++) {
                    stream = stream.pipe($.inject(gulp.src(prependSource(config.inject.source[i])), config.inject.starttag[i]));
                  }
                  
                  stream.pipe($.size())
                        .pipe(gulp.dest(dest));
                  
                  return stream;
                  

                  这篇关于如何在 gulp 中创建重复管道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Gulp-sass 无法编译 scss 文件 下一篇:如何从以前的 typescript(.ts) 文件中删除已编译的

                  相关文章

                  最新文章

                  <tfoot id='xSTVT'></tfoot>

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

                  <legend id='xSTVT'><style id='xSTVT'><dir id='xSTVT'><q id='xSTVT'></q></dir></style></legend>

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

                    • <bdo id='xSTVT'></bdo><ul id='xSTVT'></ul>