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

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

      <legend id='on7ws'><style id='on7ws'><dir id='on7ws'><q id='on7ws'></q></dir></style></legend>
        <bdo id='on7ws'></bdo><ul id='on7ws'></ul>

      <tfoot id='on7ws'></tfoot>

      在继续下一个任务之前使 gulp 同步写入文件

      时间:2023-05-29

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

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

                <tfoot id='ErWXq'></tfoot>
                  <tbody id='ErWXq'></tbody>
              1. 本文介绍了在继续下一个任务之前使 gulp 同步写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                gulpfile.js

                gulpfile.js

                gulp.task('browser-bundle', ['react'], function() {
                ...
                
                });
                
                
                gulp.task('react', function(){
                  gulp.src(options.JSX_SOURCE)
                      .pipe(react())
                      .pipe(gulp.dest(options.JSX_DEST))
                });
                

                如您所见,我有浏览器捆绑任务,具体取决于反应任务.我相信这可以按预期工作,因为在输出中我看到了:

                As you can see I have the browser-bundle task depending on the react task. I believe this works as expected because in the output I see this:

                [gulp] Running 'react'...
                [gulp] Finished 'react' in 3.43 ms
                [gulp] Running 'browser-bundle'...
                

                然而,虽然 react 任务已经完成,但它应该写入操作系统的文件还没有完全到位.我注意到,如果我在浏览器捆绑命令中添加了一个 sleep 语句,那么它会按预期工作,但这对我来说似乎有点 hacky.

                However, although the react task is finished, the files its supposed to write to the operating system are not quite there yet. I've notice that if I put a sleep statement in the browser bundle command then it works as expected, however this seems a little hacky to me.

                如果我希望在文件(来自 gulp.dest)被同步写入磁盘之前不认为反应任务完成,我该怎么做?

                If I want the react task to not be considered finished until the files (from gulp.dest) have been synchronously written to disk how would I do that?

                推荐答案

                你需要一个return语句:

                You need a return statement:

                gulp.task('react', function(){
                    return gulp.src(options.JSX_SOURCE)
                        .pipe(react())
                        .pipe(gulp.dest(options.JSX_DEST))
                });
                

                这样,我所有的写操作都在下一个任务处理之前完成.

                With this all my write operations are done before the next task processed.

                这篇关于在继续下一个任务之前使 gulp 同步写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:使用 Gulp 的 ES6 导入模块 下一篇:如何使用打字稿文件运行 gulp

                相关文章

                最新文章

                  <bdo id='IVtV4'></bdo><ul id='IVtV4'></ul>
              2. <tfoot id='IVtV4'></tfoot>
              3. <small id='IVtV4'></small><noframes id='IVtV4'>

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