浏览器同步未使用gulp重新加载 [英] Browser Sync not reloading with gulp
本文介绍了浏览器同步未使用gulp重新加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试吞下浏览器同步,如下所示
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
});
现在,当我对js文件进行更改时,我会在终端上看到以下内容:
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?
推荐答案
我在做一个简单的错误:
I was doing a simple mistake:
我们实际上需要提及要重新加载的文件,如下所示:
We actually need to mention which file to reload as follows:
liveReload.reload('./index.html');
那行得通!
这篇关于浏览器同步未使用gulp重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文