<tfoot id='0OQTs'></tfoot>
  • <legend id='0OQTs'><style id='0OQTs'><dir id='0OQTs'><q id='0OQTs'></q></dir></style></legend>
      • <bdo id='0OQTs'></bdo><ul id='0OQTs'></ul>

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

        <small id='0OQTs'></small><noframes id='0OQTs'>

        每次 Gulpfile 更改后如何重新启动 Gulp?

        时间:2023-05-29
        <i id='wZY5v'><tr id='wZY5v'><dt id='wZY5v'><q id='wZY5v'><span id='wZY5v'><b id='wZY5v'><form id='wZY5v'><ins id='wZY5v'></ins><ul id='wZY5v'></ul><sub id='wZY5v'></sub></form><legend id='wZY5v'></legend><bdo id='wZY5v'><pre id='wZY5v'><center id='wZY5v'></center></pre></bdo></b><th id='wZY5v'></th></span></q></dt></tr></i><div id='wZY5v'><tfoot id='wZY5v'></tfoot><dl id='wZY5v'><fieldset id='wZY5v'></fieldset></dl></div>

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

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

        • <tfoot id='wZY5v'></tfoot>
          <legend id='wZY5v'><style id='wZY5v'><dir id='wZY5v'><q id='wZY5v'></q></dir></style></legend>
            <tbody id='wZY5v'></tbody>

                  本文介绍了每次 Gulpfile 更改后如何重新启动 Gulp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在开发一个 Gulpfile.可以让它一改变就重新启动吗?我正在使用 CoffeeScript 开发它.Gulp 是否可以监视 Gulpfile.coffee 以便在保存更改时重新启动?

                  I am developing a Gulpfile. Can it be made to restart as soon as it changes? I am developing it in CoffeeScript. Can Gulp watch Gulpfile.coffee in order to restart when changes are saved?

                  推荐答案

                  您可以创建一个 taskgulp.watch 用于 gulpfile.js 并简单地 spawn 另一个 gulp child_process.

                  You can create a task that will gulp.watch for gulpfile.js and simply spawn another gulp child_process.

                  var gulp = require('gulp'),
                      argv = require('yargs').argv, // for args parsing
                      spawn = require('child_process').spawn;
                  
                  gulp.task('log', function() {
                    console.log('CSSs has been changed');
                  });
                  
                  gulp.task('watching-task', function() {
                    gulp.watch('*.css', ['log']);
                  });
                  
                  gulp.task('auto-reload', function() {
                    var p;
                  
                    gulp.watch('gulpfile.js', spawnChildren);
                    spawnChildren();
                  
                    function spawnChildren(e) {
                      // kill previous spawned process
                      if(p) { p.kill(); }
                  
                      // `spawn` a child `gulp` process linked to the parent `stdio`
                      p = spawn('gulp', [argv.task], {stdio: 'inherit'});
                    }
                  });
                  

                  我使用 yargs 来接受主要任务",一旦我们需要重新启动.所以为了运行它,你会调用:

                  I used yargs in order to accept the 'main task' to run once we need to restart. So in order to run this, you would call:

                  gulp auto-reload --task watching-task
                  

                  要进行测试,请调用 touch gulpfile.jstouch a.css 以查看日志.

                  And to test, call either touch gulpfile.js or touch a.css to see the logs.

                  这篇关于每次 Gulpfile 更改后如何重新启动 Gulp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:gulp.run 已弃用.如何编写任务? 下一篇:如何使用 Gulp 复制多个文件并保持文件夹结构

                  相关文章

                  最新文章

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

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

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