Skip to content

Instantly share code, notes, and snippets.

@aarongustafson
Last active September 21, 2016 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarongustafson/de368a73205d68436bb49c40a8f9fb17 to your computer and use it in GitHub Desktop.
Save aarongustafson/de368a73205d68436bb49c40a8f9fb17 to your computer and use it in GitHub Desktop.
var gulp = require('gulp'),
newer = require('gulp-newer'),
imagemin = require('gulp-imagemin'),
notify = require('gulp-notify'),
webp = require('gulp-webp');
gulp.task('images', function() {
var source = './source/images',
destination = './deploy/i';
// Optimize & move
gulp.src( source + '/**/*.{jpg,png,svg,gif}')
// Only new stuff
.pipe(newer(destination))
// Optimize
.pipe(imagemin())
// Copy
.pipe(gulp.dest(destination))
;
// Make WebP versions or PNG & JPG
gulp.src(source + '/**/*.{jpg,png}')
// Only new stuff
.pipe(newer(destination))
// WebP
.pipe(webp())
// Publish
.pipe(gulp.dest(destination))
;
return true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment