Open jongunter opened 7 years ago
Hello, I don't think this is an issue.
When you run gulp reload
task, the whole code will be executed again(include require('browser-sync').create()
), which will create another browsersync instance. And it's not related with your previous one. That's why it's not working.
The CLI is working because it's using http protocol and will communicate your current browsersync server.
If you want to refresh your page manually, please just do CLI browser-sync reload
, If you really want to use it in gulp, please consider an alternative way to do that.
First, run which browser-sync
Then, change the path to browser-sync.
gulp.task('reload', function(done){
var exec = require('child_process').exec;
var child = exec("/path/to/browser-sync reload", function (error, stdout, stderr) {
if (error !== null) {
console.log('exec error: ' + error);
}
done();
});
});
If you want to refresh your page automatically, please consider to use inside your init function.
Like
gulp.task('bs', function(){
browserSync.init(
{
// URL of an ASP.net MVC application running in Visual Studio
proxy: "localhost:3030"
}
);
gulp.watch("*.html").on("change", browserSync.reload);
}
Hope it help.
Issue details
I've started a BrowserSync instance in my gulpfile. I can call
browser-sync reload
from the command prompt, but it does not work when I run it as a gulp task. See my example below:Please provide issue details here.
After running this gulp task, I can call
browser-sync reload
from the command prompt and the page reloadsHowever, if I run my
gulp reload
, task the page does not reload.Please specify which version of Browsersync, node and npm you're running
Affected platforms
Browsersync use-case