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

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

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

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

        在 gulp 任务中删除文件

        时间:2023-05-29

      2. <tfoot id='nZqxz'></tfoot>
        <legend id='nZqxz'><style id='nZqxz'><dir id='nZqxz'><q id='nZqxz'></q></dir></style></legend>

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

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

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

                <tbody id='nZqxz'></tbody>

                  本文介绍了在 gulp 任务中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个 gulp 任务,我想获取一些源文件并将它们复制到 build/premiumbuild/free 然后从构建/免费.

                  我的尝试是这样做的:

                  gulp.task("build", ["clean"], function () {gulp.src(["src/*", "!src/composer.*", "LICENSE"]).pipe(gulp.dest("build/premium")).pipe(del(["build/free/plugins/*", "!build/free/plugins/index.php"])).pipe(gulp.dest("build/free"));});

                  这会导致错误:

                  TypeError: dest.on 不是函数在 DestroyableTransform.Stream.pipe (stream.js:45:8)在 Gulp.<匿名>(/Users/gezim/projects/myproj/gulpfile.js:9:6)

                  如何在删除端口时完成此操作?有没有更好的方法来做到这一点?

                  解决方案

                  我会使用 gulp-filter 只删除不应该从第二个目的地复制的内容.

                  我将任务的意图解释为希望 src 中存在的所有内容都存在于 build/premium 中.但是,build/free 应该排除最初在 src/plugins 中但仍应包含 src/plugins/index.php 的所有内容.p>

                  这是一个有效的 gulpfile:

                  var gulp = require("gulp");var filter = require("gulp-filter");变种德尔=要求(德尔");gulp.task("干净", function () {返回德尔(构建");});gulp.task("build", ["clean"], function () {返回 gulp.src(["src/**", "!src/composer.*", "LICENSE"]).pipe(gulp.dest("build/premium")).pipe(filter(["**", "!plugins/**", "plugins/index.php"])).pipe(gulp.dest("build/free"));});

                  传递给 filter 的模式是 relative 路径.由于 gulp.src 模式具有 src/** 这意味着它们是相对于 src 的.

                  还要注意,del 不能直接传递给 .pipe(),因为它返回一个承诺.它可以从任务中返回,就像 clean 任务一样.

                  I have a gulp task in which I want to take some source files and copy them to build/premium and build/free and then remove some extra files from build/free.

                  My attempt at that was doing this:

                  gulp.task("build", ["clean"], function () {
                    gulp.src(["src/*", "!src/composer.*", "LICENSE"])
                      .pipe(gulp.dest("build/premium"))
                      .pipe(del(["build/free/plugins/*", "!build/free/plugins/index.php"]))
                      .pipe(gulp.dest("build/free"));
                  });
                  

                  Which results in an error:

                  TypeError: dest.on is not a function
                      at DestroyableTransform.Stream.pipe (stream.js:45:8)
                      at Gulp.<anonymous> (/Users/gezim/projects/myproj/gulpfile.js:9:6)
                  

                  How do I accomplish this the deleting port? Is there a better way altogether to do this?

                  解决方案

                  I would use gulp-filter to drop only what should not be copied from the 2nd destination.

                  I interpreted the intent of the task as wanting everything present in src to be present in build/premium. However, build/free should exclude everything which was originally in src/plugins but should still include src/plugins/index.php.

                  Here is a working gulpfile:

                  var gulp = require("gulp");
                  var filter = require("gulp-filter");
                  var del = require("del");
                  
                  gulp.task("clean", function () {
                    return del("build");
                  });
                  
                  gulp.task("build", ["clean"], function () {
                    return gulp.src(["src/**", "!src/composer.*", "LICENSE"])
                      .pipe(gulp.dest("build/premium"))
                      .pipe(filter(["**", "!plugins/**", "plugins/index.php"]))
                      .pipe(gulp.dest("build/free"));
                  });
                  

                  The patterns passed to filter are relative paths. Since the gulp.src pattern has src/** it means they are relative to src.

                  Note also that del cannot be passed straight to .pipe() as it returns a promise. It can be returned from a task, like the clean task does.

                  这篇关于在 gulp 任务中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何同时使用“gulp-babel"和“gulp-browserify&qu 下一篇:无法使用 browserify 和 debowerify 获取外部库

                  相关文章

                  最新文章

                    <tfoot id='wabVi'></tfoot>

                    1. <legend id='wabVi'><style id='wabVi'><dir id='wabVi'><q id='wabVi'></q></dir></style></legend>

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

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