Last active
July 16, 2018 03:01
-
-
Save Blake-C/6529985ec51d187d2270bacaced852b9 to your computer and use it in GitHub Desktop.
Gulp image resize task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.npmjs.com/package/gulp-gm | |
// https://www.npmjs.com/package/gulp-newer | |
gulp.task('images', () => { | |
return gulp.src( `${dir.theme_components}/images/**/*` ) | |
.pipe( $.newer( `${dir.assets}/images` ) ) | |
.pipe( $.gm( gmfile => { | |
return gmfile.resize( 1300, 1300 ); | |
})) | |
.pipe( $.imagemin({ | |
progressive: true, | |
interlaced: true, | |
svgoPlugins: [{ | |
// don't remove IDs from SVGs, they are often used | |
// as hooks for embedding and styling | |
cleanupIDs: false | |
}], | |
use: [ | |
$.imageminPngquant({ | |
quality: '65-80', | |
speed: 4 | |
}) | |
], | |
}).on( 'error', () => { | |
this.end(); | |
})) | |
.pipe( gulp.dest(`${dir.assets}/images`) ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment