• <small id='38plN'></small><noframes id='38plN'>

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

        当我输入 npm start 时如何启动 Gulp watch 任务

        时间:2023-05-28
      2. <small id='YNOOk'></small><noframes id='YNOOk'>

        • <bdo id='YNOOk'></bdo><ul id='YNOOk'></ul>
              <tbody id='YNOOk'></tbody>

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

                  <i id='YNOOk'><tr id='YNOOk'><dt id='YNOOk'><q id='YNOOk'><span id='YNOOk'><b id='YNOOk'><form id='YNOOk'><ins id='YNOOk'></ins><ul id='YNOOk'></ul><sub id='YNOOk'></sub></form><legend id='YNOOk'></legend><bdo id='YNOOk'><pre id='YNOOk'><center id='YNOOk'></center></pre></bdo></b><th id='YNOOk'></th></span></q></dt></tr></i><div id='YNOOk'><tfoot id='YNOOk'></tfoot><dl id='YNOOk'><fieldset id='YNOOk'></fieldset></dl></div>
                  本文介绍了当我输入 npm start 时如何启动 Gulp watch 任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个 gulp.js 文件,其中包括:

                  I have a gulp.js file that includes:

                  gulp.task('default', ['watch']);
                  

                  哪个启动了监视任务

                  gulp.task('watch', function(){
                    gulp.watch(productionScripts, ['autoConcat']);
                  });
                  

                  然后在 productionScripts 中对文件的任何保存更改,监视任务将连接文件.

                  Then on any saved changes to files in productionScripts, the watch task will concat the files.

                  我想做的是在我的 package.json 中,我想在我输入 npm start 时启动这个手表(这已经启动了我的节点服务器).

                  What I would like to do, is in my package.json, I would like to spool up this watch when I type npm start (this already starts my node server).

                  package.json

                  package.json

                      "start": "node server.js",
                  

                  更新--------

                  Ben(b3nj4m.com),我试过你所说的.手表和服务器启动.但是,一切都运行了两次(可能是由于编辑器,不相关),但是当我使用 gulp 启动它时,我确实丢失了我的服务器日志.

                  Ben(b3nj4m.com), I tried what you stated. The watch and server start up. However, everything runs twice (probably due to the editor, not related), but I do lose my server log when I start it up with gulp.

                  [15:31:18] Starting 'autoConcat'...
                  [15:31:18] Finished 'autoConcat' after 147 ms
                  [15:31:19] Starting 'autoConcat'...
                  [15:31:19] Finished 'autoConcat' after 138 ms
                  [15:31:20] Starting 'autoConcat'...
                  [15:31:20] Finished 'autoConcat' after 127 ms
                  [15:31:23] Starting 'autoConcat'...
                  

                  这就像在服务器因更改而重新启动和级联文件更改之间存在一个循环.

                  It's like there is a loop between the server restarting on a change, and the concatenated file changing.

                  推荐答案

                  你可以从你的 gulpfile 运行你的服务器:

                  You could run your server from your gulpfile:

                  var child = require('child_process');
                  var fs = require('fs');
                  
                  gulp.task('default', ['server', 'watch']);
                  
                  gulp.task('server', function() {
                    var server = child.spawn('node', ['server.js']);
                    var log = fs.createWriteStream('server.log', {flags: 'a'});
                    server.stdout.pipe(log);
                    server.stderr.pipe(log);
                  });
                  
                  gulp.task('watch', function(){
                    gulp.watch(productionScripts, ['autoConcat']);
                  });
                  

                  然后将您的 npm start 定义更改为:

                  Then change your npm start definition to look like:

                  "scripts": {
                    "start": "gulp"
                  }
                  

                  这篇关于当我输入 npm start 时如何启动 Gulp watch 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:缓存在 SASS 文件中链接的破坏图像 下一篇:Gulp 手表不工作

                  相关文章

                  最新文章

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

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

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

                    <tfoot id='RXEIW'></tfoot>