A
A
Arthur2017-07-31 13:16:34
css
Arthur, 2017-07-31 13:16:34

Why is gulp looping?

Changing and saving a file watched by watch causes a browser refresh loop. In the console, the constant updating of prntscr.com/g2gjo2, after 30 updates, stops.
If at this moment you continue to make edits to the file, the sublime stupefies reacting that changes have occurred and asks to update them, after which the prntscr.com/g2gkct refresh continues anyway .
The day before, everything was updated correctly

var gulp 		= require("gulp"), //lib gulp
  browserSync = require("browser-sync"), //lib 4 browser reload and server
  csscomb		= require("gulp-csscomb"), //lib 4 lint css
  del			= require("del"); //lib 4 clean


// очистка папки dist
gulp.task('del', function(){
  return del.sync('dist');
});


//очистка рабочей папки app
// gulp.task('del-app', function(){
// 	del(['app/css/*.*','!app/css/style.css','app/fonts/*.*','app/img/*.*','app/js/*.*']);
// });


//сборка проекта
gulp.task('build', ['del','csscomb'], function(){
  var	buildcCss = gulp.src('app/css/**.css')
  .pipe(gulp.dest('dist/css'))

  var buildHtml = gulp.src('app/**.html')
  .pipe(gulp.dest('dist/'))

  var buildImg = gulp.src('app/img/**.*')
  .pipe(gulp.dest('dist/img'))

  var buildJs = gulp.src('app/js/**.*')
  .pipe(gulp.dest('dist/js')); 
});



//минификация стилей
gulp.task('csscomb', function(){
  return gulp.src('app/css/*.css')
    .pipe(csscomb())
    .pipe(gulp.dest('app/css/'));
});


//создание сервера для просмотра
gulp.task('browser-sync', function () {
  browserSync({
    server:{
      baseDir:'app'
    },
    notify:false,
    online:false,
  });
});


// слежка за изменением файлов
gulp.task('watch', ['browser-sync','csscomb'], function(){
  gulp.watch('app/css/*.css', ['csscomb']);
  gulp.watch('app/css/*.css', browserSync.reload);
  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