Browser Sync not reloading with gulp

被刻印的时光 ゝ 提交于 2019-12-23 16:37:36

问题


I am trying to gulp browser sync as follows

var liveReload = require('browser-sync').create();

//reload when something changes once scss is converted to css
gulp.task('trigger-reload', ['sass'], function(){
    liveReload.reload();
});

//set watchers to reload
gulp.task('watch', function(){
    liveReload.init({
        server: {
            baseDir:'./'
        }
    });
    gulp.watch('src/**/*.js', ['trigger-reload']); //js change
});

Now when I make changes to the js file I see the following on my terminal :

[00:19:23] Starting 'trigger-reload'...
[BS] Reloading Browsers...
[00:19:23] Finished 'trigger-reload' after 282 μs

But it actually does not refresh the page, I have to manually refresh to see my changes. Any suggestions on what I am missing here?


回答1:


I was doing a simple mistake:

We actually need to mention which file to reload as follows:

 liveReload.reload('./index.html');

That works!



来源:https://stackoverflow.com/questions/31041823/browser-sync-not-reloading-with-gulp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!