P
P
pasha bpv2014-10-24 20:14:31
gulp.js
pasha bpv, 2014-10-24 20:14:31

Why doesn't gulp-imagemin compress files?

Tell me what's the matter, the gulp-Imagemin plugin does not compress image files?
here is the configuration:

var gulp = require('gulp'),
    concat = require('gulp-concat'),
    rename = require('gulp-rename'),
    notify = require('gulp-notify'),
    minifyCSS = require('gulp-minify-css'),
    autoprefixer = require('gulp-autoprefixer'),
    livereload = require('gulp-livereload'),
    connect = require('gulp-connect'),
    plumber = require('gulp-plumber'),
    imagemin = require('gulp-imagemin');

// server connect
gulp.task('connect', function() {
  connect.server({
    root: 'dev',
    livereload: true
  });
});

// html
gulp.task('html', function(){
  gulp.src('dev')
  .pipe(connect.reload());
});

// css
gulp.task('css', function () {
  gulp.src('dev/style/css/*.css')
    .pipe(plumber())
    .pipe(concat("style.css"))
    .pipe(autoprefixer({
            browsers: ['last 15 versions']
        }))
    .pipe(minifyCSS())
    .pipe(rename('style.min.css'))
    .pipe(gulp.dest('dev/style/css/'))
    .pipe(connect.reload());
});

// Image Task
// Compress
gulp.task('image', function(){
  gulp.src('dev/style/img/sourse/**/*.{jpg,jpeg,png,gif}')
  .pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
  .pipe(gulp.dest('dev/style/img'));
});


// watch
gulp.task('watch', function(){
  gulp.watch('dev/style/css/*.css', ['css'])
  gulp.watch('dev/*.html', ['html'])
  gulp.watch('dev/style/img/sourse/**/*', ['image']);

});

// default
gulp.task('default', ['connect',
                      'image',
                      'html',
                      'css',
                      'watch'
                      ]);

And here's what's in the console:
[21:13:37] Starting 'connect'...
[21:13:37] Server started http://localhost:8080
[21:13:37] LiveReload started on port 35729
[21:13:37] Finished 'connect' after 65 ms
[21:13:37] Starting 'image'...
[21:13:37] Finished 'image' after 11 ms
[21:13:37] Starting 'html'...
[21:13:37] Finished 'html' after 1.77 ms
[21:13:37] Starting 'css'...
[21:13:37] Finished 'css' after 7.79 ms
[21:13:37] Starting 'watch'...
[21:13:38] Finished 'watch' after 55 ms
[21:13:38] Starting 'default'...
[21:13:38] Finished 'default' after 11 μs
[21:13:38] gulp-imagemin: Minified 8 images (saved 0 B - 0%)
[21:13:38] Starting 'css'...
[21:13:38] Finished 'css' after 3.85 ms

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Askhat Bikmetov, 2014-10-24
@askhat

Try changing optimizationLevel . If this solves the problem, obviously the files were already optimal according to the optimizationLevel value .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question