-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
52 lines (44 loc) · 1.12 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
41
42
43
44
45
46
47
48
49
50
51
52
var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var imageResize = require('gulp-image-resize');
var webserver = require('gulp-webserver');
gulp.task('default', ['resize', 'optimize'], function () {
});
gulp.task('serve', function() {
gulp.src('.')
.pipe(webserver({
livereload: false,
directoryListing: false,
open: true
}));
});
function resize(path) {
return gulp.src(path)
.pipe(imageResize({
width : 1200,
crop : false,
upscale : false
}))
.pipe(gulp.dest('img'));
}
gulp.task('resize', ['resize-png', 'resize-jpg', 'resize-gif'], function() {
});
gulp.task('resize-png', function() {
return resize('img/*.png')
});
gulp.task('resize-jpg', function() {
return resize('img/*.jpg')
});
gulp.task('resize-gif', function() {
return resize('img/*.gif')
});
gulp.task('optimize', function () {
return gulp.src('img/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('img'));
});