Answer the question
In order to leave comments, you need to log in
How to cure [Browsersync] Reloading Browsers... (buffered 4 events)?
Hello! There are such sections of code!
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: 'app'
}
});
browserSync.watch('app/**/*.*').on('change', browserSync.reload);
});
gulp.task('html', function () {
return gulp.src(path.src.html)
.pipe(gulp.dest(path.app.html))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('watch', function () {
gulp.watch(path.src.html, gulp.series('html'));
});
gulp.task('default', gulp.series(
gulp.parallel('watch', 'browser-sync') //запускаем паралельно слежку за файлами и синхронизацию браузера
));
[14:59:51] Starting 'default'...
[14:59:51] Starting 'watch'...
[14:59:51] Starting 'browser-sync'...
[Browsersync] Access URLs:
-------------------------------------
Local: http://localhost:3000
External: http://192.168.1.92:3000
-------------------------------------
UI: http://localhost:3001
UI External: http://localhost:3001
-------------------------------------
[Browsersync] Serving files from: app
[14:59:57] Starting 'html'...
[Browsersync] 2 files changed (404.html, index.html)
[14:59:57] Finished 'html' after 66 ms
[Browsersync] Reloading Browsers... (buffered 4 events)
[Browsersync] Reloading Browsers... (buffered 4 events)
Answer the question
In order to leave comments, you need to log in
The code is incorrect, change tracking does not need to be scattered in different places, the browser update is written in the series, and not in the task. In gulp 4, the update will work correctly with this spelling:
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: 'app'
}
});
});
gulp.task('html', function () {
return gulp.src(path.src.html)
.pipe(gulp.dest(path.app.html));
});
gulp.task('watch', function () {
gulp.watch('app/**/*.*').on('change', browserSync.reload);
gulp.watch(path.src.html).on('change', gulp.series(html, browserSync.reload));
});
gulp.task('default', gulp.series(
gulp.parallel('watch', 'browser-sync') //запускаем паралельно слежку за файлами и синхронизацию браузера
));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question