forked from udacity/mws-restaurant-stage-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
40 lines (37 loc) · 1.28 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const gulp = require('gulp');
const imagemin = require('gulp-imagemin');
const responsive = require('gulp-responsive');
gulp.task('compressImages', () => {
gulp.src('img/*.jpg')
.pipe(imagemin())
.pipe(gulp.dest('img'));
});
gulp.task('responsiveImages', () => {
return gulp.src('img/*.jpg')
.pipe(responsive({
// Resize all JPG images to three different sizes: 200, 500, and 630 pixels
'*.jpg': [{
width: 200,
rename: { suffix: '-200px' },
}, {
width: 500,
rename: { suffix: '-500px' },
}, {
width: 630,
rename: { suffix: '-630px' },
}, {
// Compress, strip metadata, and rename original image
rename: { suffix: '-original' },
}],
}, {
// Global configuration for all images
// The output quality for JPEG, WebP and TIFF output formats
quality: 70,
// Use progressive (interlace) scan for JPEG and PNG output
progressive: true,
// Strip all metadata
withMetadata: false,
}))
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['compressImages', 'responsiveImages']);