Skip to content

Instantly share code, notes, and snippets.

@shelldandy
Created July 18, 2018 14:36
Show Gist options
  • Save shelldandy/75fb7d2c667ec1af9cbc2d1fe97bdb56 to your computer and use it in GitHub Desktop.
Save shelldandy/75fb7d2c667ec1af9cbc2d1fe97bdb56 to your computer and use it in GitHub Desktop.

Revisions

  1. shelldandy renamed this gist Jul 18, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. shelldandy created this gist Jul 18, 2018.
    46 changes: 46 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    const gulp = require('gulp')
    const imagemin = require('gulp-imagemin')
    const imageminPngquant = require('imagemin-pngquant');
    const imageminZopfli = require('imagemin-zopfli');
    const imageminMozjpeg = require('imagemin-mozjpeg'); // need to run 'brew install libpng'
    const imageminGiflossy = require('imagemin-giflossy');

    gulp.task('esketit', () =>
    gulp.src(['src/**/*.{gif,png,jpg,jpeg,svg}'])
    .pipe(imagemin([
    // png
    imageminPngquant({
    speed: 1,
    quality: 98 // lossy settings
    }),
    imageminZopfli({
    more: true
    }),
    imageminGiflossy({
    optimizationLevel: 3,
    optimize: 3, // keep-empty: Preserve empty transparent frames
    lossy: 2
    }),
    // svg
    // copied these values from the sketch svgo plugin
    imagemin.svgo({
    plugins: [
    {
    cleanupListOfValues: true
    },
    {
    sortAttrs: true
    }
    ]
    }),
    // jpg lossless
    imagemin.jpegtran({
    progressive: true
    }),
    // jpg very light lossy, use vs jpegtran
    imageminMozjpeg({
    quality: 90
    })
    ]))
    .pipe(gulp.dest('dist'))
    );