U
U
unsxxndxrk2018-08-31 19:21:34
gulp.js
unsxxndxrk, 2018-08-31 19:21:34

Gulp 4 - Browsersync is constantly processing files, what's the problem?

Updated Gulp to version 4.0.0 and ran into the following issue. There is gulpfile.js, and when the watch browsersync task is launched, it constantly processes js files without editing the code in the files, and messages are displayed to the console every second that js files have been changed, and the page is constantly updated. But this problem is observed only when the 'js' task is in the Watch task in the gulp.parallel() function. The order of tasks is the same as in my file. Who knows what is wrong in the code? Thank you.

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

gulp.task('js', function() {
  return gulp.src([
    'app/js/jquery-3.3.1.min.js',
    'app/js/main.js' // always in the end
    ])
  .pipe(concat('scripts.min.js'))
  .pipe(uglify())
  .pipe(gulp.dest('app/js'))
  .pipe(browserSync.reload({stream: true})); 
});

    gulp.task('sass', function() {
  return gulp.src('app/sass/**/*.sass')
  .pipe(sass({outputStyle: 'expand'}).on("error", notify.onError()))
  .pipe(rename({suffix: '.min', prefix : ''}))
  .pipe(autoprefixer(['last 15 versions']))
  .pipe(cleanCSS())
  .pipe(gulp.dest('app/css'))
  .pipe(browserSync.reload({stream: true})); 
});

    gulp.task('watch', function(cb) {
  gulp.parallel(
    'sass', 
    'js', 
    'browser-sync'
  )(cb);
  
  gulp.watch('app/sass/**/*.sass', gulp.series('sass'));
  gulp.watch(['app/js/**/*.js', 'app/js/main.js'], gulp.series('js'));
  gulp.watch('app/*.html', browserSync.reload); 
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question