Answer the question
In order to leave comments, you need to log in
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);
});
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))
});
gulp.task('default', gulp.series( 'css', gulp.parallel('server-dev', 'watch')));
Answer the question
In order to leave comments, you need to log in
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();
});
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 questionAsk a Question
731 491 924 answers to any question