Skip to content

Instantly share code, notes, and snippets.

@ihorduchenko
Created October 22, 2018 09:11
Show Gist options
  • Save ihorduchenko/2e796bcd004200f4668cfb38fbbf07a8 to your computer and use it in GitHub Desktop.
Save ihorduchenko/2e796bcd004200f4668cfb38fbbf07a8 to your computer and use it in GitHub Desktop.
Gulpfile for minifying images using gulp and gulp-image NPM packages
const gulp = require('gulp'),
image = require('gulp-image');
const src = './uploads/**/*.{jpg,JPG,jpeg,JPEG,png,svg,gif}',
dist = './uploads-min/';
gulp.task('image', function () {
gulp.src(src)
.pipe(image({
pngquant: true,
optipng: false,
zopflipng: true,
jpegRecompress: false,
mozjpeg: true,
guetzli: false,
gifsicle: true,
svgo: true,
concurrent: 10,
quiet: true // defaults to false
}))
.pipe(gulp.dest(dist))
});
{
"name": "images",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-image": "^4.3.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment