Repository navigation
Expand file tree
/
Copy pathgulpfile.js
More file actions
64 lines (63 loc) · 1.78 KB
/
Copy pathgulpfile.js
File metadata and controls
64 lines (63 loc) · 1.78 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const gulp = require('gulp');
const $ = require('gulp-load-plugins')();
gulp.task('default', function() {
return gulp.src('images/master/*.{jpg,png,tiff}')
.pipe($.responsive({
'*.{jpg,png,tiff}': [{
width: 300,
rename: {
suffix: '-300px',
extname: '.jpg',
},
format: 'jpeg',
}, {
width: 600,
rename: {
suffix: '-600px',
extname: '.jpg',
},
// format option can be omitted because
// format of output image is detected from new filename
// format: 'jpeg'
}, {
width: 600 * 2,
rename: {
suffix: '-600@2x',
extname: '.jpg',
},
}, {
width: 600 * 2,
rename: {
suffix: '-600@2x',
extname: '.webp',
},
}, {
width: 1900,
rename: {
suffix: '-1900px',
extname: '.jpg',
},
// Do not enlarge the output image if the input image are
// already less than the required dimensions.
withoutEnlargement: true,
}, {
// Convert images to the webp format
width: 1900,
rename: {
suffix: '-1900px',
extname: '.webp',
},
}],
}, {
// Global configuration for all images
// The output quality for JPEG, WebP and TIFF output formats
quality: 80,
// Use progressive (interlace) scan for JPEG and PNG output
progressive: true,
// Strip all metadata
withMetadata: false,
// Do not emit the error when image is enlarged.
errorOnEnlargement: false,
}))
.pipe(gulp.dest('images/converted'));
});