https://www.tutorialspoint.com/gulp/gulp_optimizing_images.htm
npm install gulp-changed --save-dev npm install gulp-imagemin --save-dev
var gulp = require('gulp'); var changed = require('gulp-changed'); var imagemin = require('gulp-imagemin');
gulp.task('imagemin', function() { var imgSrc = 'src/images/*.+(png|jpg|gif)', imgDst = 'build/images'; gulp.src(imgSrc) .pipe(changed(imgDst)) .pipe(imagemin()) .pipe(gulp.dest(imgDst)); }); gulp.task('default',['imagemin'],function(){ });
Last updated 3 years ago
Was this helpful?