-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Browsersync reload in a loop #1324
Comments
I specify that my files are in folders and in subfolders. var templatesFolder = siteSources + 'templates/';
var templatesInput = templatesFolder + '**/*.njk'; I did test again. I added a task that launches njk task once it is finished. gulp.task('njk-watch', ['njk'], function (done) {
browserSync.reload();
done();
}); And I call this task in my watcher. But doesn't work, reloading it's not done. Strange because it's the recommended method in the doc https://browsersync.io/docs/gulp#gulp-reload If I remove 'return' on my main task 'njk'. In this case there is no more multiple reloading. But the reloading is before the end of the njk task. gulp.task('njk', function () {
gulp.src(templatesInput)
.pipe(nunjucksRender({
.... For the moment the only way is to remove return on 'njk task' and add a setTimeout but I think there is a best method. gulp.task('njk', function () {
gulp.src(templatesInput)
.pipe(nunjucksRender({
path: templatesFolder,
ext: '.html'
}))
.pipe(gulp.dest(templatesOutput));
});
// Reload browser after 2.5s
gulp.task('njk-watch', ['njk'], function (done) {
setTimeout(function() {
browserSync.reload();
}, 2500);
done();
}); Thanks a lot for your help. |
Could it be that your |
I am having a similar issue with gulp and browser-sync 2.18.8. Everything works fine on 2.18.7. Every time I save a file, browser-sync outputs "[BS] Reloading Browsers" multiple times (once for each watched file) and reloads the browser that many times. On 2.18.7 it does not output "[BS] Reloading Browsers" at all, but the browser does reload once. const gulp = require('gulp');
const browserSync = require('browser-sync');
const $ = require('gulp-load-plugins')();
gulp.task('scripts', function () {
return gulp.src('src/app/**/*.js')
.pipe($.sourcemaps.init())
.pipe($.sourcemaps.write())
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
.pipe(browserSync.reload({ stream: true }))
.pipe($.size())
}); Edit: |
Any plans to fix this in the near future? Just ran into that bug again in 2021. |
I had similar issue with scripts. The bundled JS files (*.bundle.js) lied in the folder I watched was causing multiple reloads. This is helped me (exclude *.bundle.js from watch with !): const reload = (done) => {
browserSync.reload();
done();
}; gulp.watch(['js/**/*.js', '!js/**/*.bundle.js'], gulp.series('scripts', reload)); |
Hi
Issue details
For some time I have a problems with Browsersync. I have a web front-end workflow with Gulp, Browsersync, SASS and Nunjucks. Gulp compile my Nunjucks files. At the end of this task, browser is reloaded with Browsersync. Before a few days browsersync reloaded browser just once. Now it reload browser as many times as there are nunjucks files.
Please specify which version of Browsersync, node and npm you're running
Affected platforms
Browsersync use-case
The text was updated successfully, but these errors were encountered: