A
A
Artur Masloboev2016-05-16 19:23:18
gulp.js
Artur Masloboev, 2016-05-16 19:23:18

Is gulp processing new files slower each time?

Hello!
I am using gulp4.
There is a problem that when I add a new file, it is processed slowly and the execution time of the task associated with it increases with each save.
At the same time, all other files that were before the start of the gulp task work properly.
Watcher:

gulp.task('watch', function() {
  gulp.watch([`${path.styles}/style.css`, `${path.styles}/utils/**/*.css`, `${path.styles}/base/**/*.css`, `${path.blocks}/**/*.css`], gulp.series('css'));
  gulp.watch([`${path.dev}/*.html`, `${path.styles}/style.compiled.css`, `${path.scripts}/app.compiled.js`]).on('change', browserSync.reload);
});

Handler task:
gulp.task('css', function() {
  return gulp.src([`${path.styles}/style.css`])
    .pipe(postcss(plugins, { parser: sugarss })).on('error', log)
    .pipe(rename({
      suffix: '.compiled',
      extname: '.css'
    }))
    .pipe(csso()).on('error', log)
    .pipe(gulp.dest(path.styles))
});

Launch task:
gulp.task('default', gulp.series( 'css', gulp.parallel('server-dev', 'watch')));

If you have any ideas on what to do with this, I would be very grateful.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artur Masloboev, 2016-05-17
@arthurmasl

It turned out to be solved. The problem was that in the 4th galp, the paths in watch should be written differently, without ./

gulp.task('watch', function(done) {
  gulp.watch(['**/*.css', '!dev/styles/style.compiled.css'], gulp.series('css'));
  gulp.watch([`${path.dev}/*.html`, `${path.styles}/style.compiled.css`, `${path.scripts}/app.compiled.js`]).on('change', browserSync.reload);

  done();
});

I also added coolbacks to the server and watch, but I'm not sure if they are needed. It works, I don't have the strength to touch it.
gulp.task('server-dev', function(done) {
  browserSync.init({
    server: {
      baseDir: path.dev
    },
    port: 8000,
    https: false,
    notify: false,
    reloadDelay: 50
  }, done);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question