Answer the question
In order to leave comments, you need to log in
Gulp-imagemin - Doesn't track a folder if it's initially empty?
Good day to all!
Question for Javascript and Gulp.js connoisseurs.
It consists in the following.
There is a Gulp Task created to optimize images:
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
browserSync = require('browser-sync'),
imagemin = require('gulp-imagemin');
// IMAGE OPTIMIZE
gulp.task('imageminTask', function(){
gulp.src(['app/images/*.{png,jpg,gif}', '!sprite/*'])
.pipe(plumber())
.pipe(imagemin({
optimizationLevel: 3,
interlaced: true,
progressive: true
}))
.pipe(gulp.dest('build/images/'));
});
// WATCH
gulp.task('watchTask', function(){
gulp.watch('app/templates/**/*.jade', ['jadeTask']);
gulp.watch('app/styles/**/*.styl', ['stylusTask']);
gulp.watch('app/scripts/**/*.js', ['javascriptTask']);
gulp.watch('app/images/*.{png,jpg,gif}', ['imageminTask']);
});
// DEFAULT
gulp.task('default', ['jadeTask', 'stylusTask', 'javascriptTask', 'imageminTask', 'browserSyncTask', 'watchTask']);
images
new images in the directory and starts the actions prescribed in it only in one case - if at the initial start images
there was already at least one image in the directory . images
was empty at the initial start of the task , then the task does not track the appearance of new images in it and does not perform its actions , respectively. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question