Browser sync does not reload with gulp

I am trying to gulp browser sync like this

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 in my terminal:

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

      

But it doesn't actually refresh the page, I need to manually refresh to see my changes. Any suggestions on what I am not seeing here?

+3


source to share


1 answer


I was making a simple mistake:

We really need to specify which file to reload like this:



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

      

It works!

-1


source







All Articles