jdsteinbach
1/25/2016 - 4:15 PM

gulpfile.js

  "devDependencies": {
    "gulp-changed": "^1.2.1",
    "gulp-imagemin": "^2.2.1"
  }
(function() {
    'use strict';

    var _img_src_dir = '/src/img/';
    var _img_dir     = '/img/';
    
    /**
     * Minimizes all the images
     */
    gulp.task('images', function() {
        var _options = {
            progressive: true,
            svgoPlugins: [{
                removeViewBox: false,
                removeHiddenElems: false
            }]
        };
        gulp.src(_img_src_dir + '/*.{png,jpg,jpeg,gif,svg}')
            .pipe($.changed(_img_dir))
            .pipe($.imagemin(_options))
            .pipe(gulp.dest(_img_dir))
        );
    });
}());