F
F
fantazerno2016-02-24 21:02:43
gulp.js
fantazerno, 2016-02-24 21:02:43

How to understand the Gulp-newer plugin?

I have the following assembly where
Gulp:
CLI version 1.2.1
Local version 4.0.0-alpha.2

var gulp = require("gulp");
var autoprefixer = require('gulp-autoprefixer');
var useref = require('gulp-useref');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var minifyCss = require('gulp-minify-css');
var stylus = require('gulp-stylus');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync').create();
var ftp = require( 'vinyl-ftp' );
var reload = browserSync.reload;
var fileinclude = require('gulp-file-include');
var axis = require('axis');
var jeet = require('jeet');
var htmlhint = require("gulp-htmlhint");
var rupture = require('rupture');
var data = require('gulp-data');
var jade = require('gulp-jade');
var notify = require('gulp-notify');
var pngquant = require('imagemin-pngquant');
var imageminMozjpeg = require('imagemin-mozjpeg');
var imagemin = require('gulp-imagemin');
var cache = require('gulp-cached');
var newer = require('gulp-newer');
var remember = require('gulp-remember');

gulp.task('imageJpg',function(){
  return gulp.src('app/img/*.jpg')
  .pipe(newer('dist/img/'))
  .pipe(imagemin({
          progressive: true,
          svgoPlugins: [{removeViewBox: false}],
          use: [imageminMozjpeg({quality: '60', speed: 11})]
      }))
  .pipe(gulp.dest('dist/img/'));
});

At the same time, newer does not want to work in any way, all images are processed, regardless of whether they are in the outgoing directory.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kleilike, 2016-07-20
@kleilike

if before "imageJpg" you don't run cleanup of files in "dist/img/", then everything should work. For clarity, use gulp-debug

gulp.task('image', function() {
  return gulp.src(path.src.image)
    .pipe(newer(path.dest.image))
    .pipe(debug({'title':' image'}))
    .pipe(gulp.dest(path.dest.image));
});

The first time I transferred all the files, the second time I did not transfer them, because they already exist

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question