W
W
Worddoc2016-10-19 23:37:34
JavaScript
Worddoc, 2016-10-19 23:37:34

Refreshing the page via browserSync overtakes compiling the files. How to cope?

Hello. Updating via browserSync works too fast, pug(jade) after compiling to html compiles and eventually updates html for too long. I don't see any other option how to put setTimeout on browserSync, but are there other, faster options?( Thanks.

gulp.task('pug', function() {
  return gulp.src('src/pug/**/*.pug')
    .pipe(pug())
    .pipe(gulp.dest('src'))
    .pipe(browserSync.reload({stream: true}))
});

gulp.task('browser-sync', function() {
  browserSync({
    server: {
      baseDir: 'src'
    },
    notify: false
  });
});

gulp.task('watch', ['browser-sync', 'pug', 'css-libs', 'scripts'], function() {
  gulp.watch('src/sass/**/*.scss', ['sass']); // Наблюдение за sass файлами в папке sass
  gulp.watch('src/pug/**/*.pug', ['pug']); // Наблюдение за HTML файлами в корне проекта
  gulp.watch('src/js/**/*.js', browserSync.reload);   // Наблюдение за JS файлами в папке js
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Korotaev, 2016-10-20
@Worddoc

need to catch the event

gulp.src('src/pug/**/*.pug')
    .pipe(pug())
    .pipe(gulp.dest('src'))
    .on('end', function() {browserSync.reload({stream: true}))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question