Answer the question
In order to leave comments, you need to log in
Why does browserSync freeze when changing files?
I recently decided to learn how to make my own gulp builds. In the project I use pug, webpack, sass and eventually decided to include browserSync.
Initially, nothing was tracked, then, after all, I achieved this (in all files with tasks, I registered .pipe (browsersync.stream ())) at the end, but the page does not reload when changes are made. In the end, the idea came to register everything in the server task.
Here is the code:
const gulp = require('gulp');
const browsersync = require('browser-sync').create();
module.exports = function browserSync(params) {
browsersync.init({
server:{
baseDir: "build"
},
port : 3000,
notify: false,
open: true,
cors: true
})
gulp.watch('#src/img/**/*.{jpg,png,svg,ico,gif,webp}').on('change', browsersync.reload);
gulp.watch("#src/js/**/*.js").on('change', browsersync.reload);
gulp.watch("#src/sass/**/*.sass").on('change', browsersync.reload);
gulp.watch("#src/**/*.pug").on('change', browsersync.reload);
}
Answer the question
In order to leave comments, you need to log in
gulp.watch("#src/sass/**/*.sass").on('change', browsersync.reload);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question