V
V
vovkka2017-08-10 08:15:12
css
vovkka, 2017-08-10 08:15:12

When adding svg files to a folder, the task does not start, how to fix it?

Good afternoon.
I rummaged everything, but it didn’t work as it should .....
there is a task

// compress svg
gulp.task('svg_compress', function () {
    gulp.src('app/img/icon_svg/*.svg')
        .pipe(imagemin({
            progressive: true,
            svgoPlugins: [{removeViewBox: false}],
            use: [pngquant()],
            interlaced: true
        }))
        .pipe(gulp.dest('app/img/icon_svg/')); 
});

and there is tracking
// revizor
gulp.task('watch', ['browser-sync'], function () {
  gulp.watch('app/img/icon_svg/**/*.svg', ['svg_compress']);
});

The problem is that when I add files to a folder and watch is running, the task does not run and does not minify svg, but when the files are in the folder and I run the task manually, everything works as it should ... why does watch not monitor the addition of new files? Thank you all!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Tallmange, 2017-08-10
@vovkka

gulp.watch does not know how to keep track of added or removed files. Use gulp-watch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question