I have a problem with Gulp and BrowserSync, is really a small issue but is bugging me.
Every time I change the scss file and I ran sass() to combile it the browser reloads and scrolls back to the top.
Is there a way to prevent the browser to do that every time I change a scss file?
By the way this is happening only on the sass task, the js and php tasks do not cause the browser to scroll to the top.
I tried Chrome and Firefox and I get the same behavior.
Here is my gulpfile.js
gulp.task('serve', ['sass'], function() {
browserSync.init({
proxy: "mysite.dev"
});
gulp.watch("styles/scss/*.scss", ['sass']);
gulp.watch("*scripts/*.js", ['js']);
gulp.watch("*.php", ['php']);
});
// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
return gulp.src("styles/scss/*.scss")
.pipe(sass())
.pipe(gulp.dest("styles/css"))
.pipe(browserSync.stream());
});
gulp.task('js', function() {
return gulp.src('scripts/*.js')
.pipe(browserSync.stream());
});
gulp.task('php', function() {
return gulp.src('*.php')
.pipe(browserSync.stream());
});
gulp.task('default', ['serve']);
Is there a way to stop that?