By
donglegend
更新日期:
网页性能优化,通常要处理图片,尤其图片量大的时候,更需要工具来批量处理,这里使用gulp。
1 2 3 4 5 6 7 8 9 10
| var gulp = require('gulp'); var imageResize = require('gulp-image-resize');
gulp.task('resize', function() { return gulp.src('./images/**/*') .pipe(imageResize({ width: 400 })) .pipe(gulp.dest('dist/resize')); });
|
1 2 3 4 5 6 7 8 9 10 11 12 13
| var gulp = require('gulp'); var imagemin = require('gulp-imagemin'); var pngquant = require('imagemin-pngquant'); gulp.task('min', function() { return gulp.src('./images/**/*') .pipe(imagemin({ progressive: true, use: [pngquant({ quality: '65-80' })] })) .pipe(gulp.dest('dist/min')); })
|