问题
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