簡體   English   中英

瀏覽器同步未在 gulp 中重新加載

[英]Browser-sync not reloading in gulp

我在終端運行 gulp 服務,然后 window 彈出。 但是,當我在.html 中進行更改時,這些更改不會重新加載到頁面上。 我不知道什么是異步完成,因為這是我第一次收到這個錯誤。

[BS] Local URL: http://localhost:3000
[BS] External URL: http://10.0.0.58:3000
[BS] Serving files from: temp
[BS] Serving files from: dev
[BS] Serving files from: dev/html
^C[15:49:48] The following tasks did not complete: serve
[15:49:48] Did you forget to signal async completion?
let serve = () => {
    browserSync({
        notify: true,
        reloadDelay: 0, // A delay is sometimes helpful when reloading at the
        server: {       // end of a series of tasks.
            baseDir: [
                `temp`,
                `dev`,
                `dev/html`
            ]
        }
    });
    watch(`dev/html/**/*.html`, series(validateHTML)).on(`change`, reload);
    watch(`dev/js/*.js`, series(lintJS, compressJS)).on(`change`, reload);
    watch (`dev/css/**/*.css`, series(compressCSS)) .on(`change`, reload);
};

Gulp 4 要求每個任務完成,以便它可以繼續以指定的順序(例如並行或串行)運行其他任務。

您收到該致命錯誤是因為您的serve任務缺少done回調,這讓 gulp 知道您已准備好開始隊列中的下一個任務。

更多信息在這里: Gulp“完成”方法有什么作用?

以下是您的serve任務的更新版本,它將允許它繼續同時運行而不會導致致命錯誤。

 let serve = (done) => { // add done as an argument browserSync({ notify: true, reloadDelay: 0, // A delay is sometimes helpful when reloading at the server: { // end of a series of tasks. baseDir: [ 'temp', 'dev', 'dev/html' ] } }); watch('dev/html/**/*.html', series(validateHTML)).on('change', reload); watch('dev/js/*.js', series(lintJS, compressJS)).on('change', reload); watch ('dev/css/**/*.css', series(compressCSS)).on('change', reload); done(); // call the done method when you are ready to move onto the next task. };

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM