-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
65 lines (60 loc) · 1.54 KB
/
gulpfile.js
File metadata and controls
65 lines (60 loc) · 1.54 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
65
var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
var imageminPngquant = require('imagemin-pngquant');
var imageminZopfli = require('imagemin-zopfli');
var imageminMozjpeg = require('imagemin-mozjpeg');
var imageminGiflossy = require('imagemin-giflossy');
var notifier = require('node-notifier');
var runSequence = require('run-sequence');
var paths = {
srcIMAGES: "src/**",
distIMAGES: "dist"
}
gulp.task('optimize', function () {
return gulp.src(paths.srcIMAGES)
.pipe(imagemin([
//png
imageminPngquant({
speed: 1,
quality: 80 //lossy settings
}),
imageminZopfli({
more: true
}),
//gif
// imagemin.gifsicle({
// interlaced: true,
// optimizationLevel: 3
// }),
//gif very light lossy, use only one of gifsicle or Giflossy
imageminGiflossy({
optimizationLevel: 3,
optimize: 3, //keep-empty: Preserve empty transparent frames
lossy: 2
}),
//svg
imagemin.svgo({
plugins: [{
removeViewBox: false
}]
}),
//jpg lossless
imagemin.jpegtran({
progressive: true
}),
//jpg very light lossy, use vs jpegtran
imageminMozjpeg({
quality: 80
})
]))
.pipe(gulp.dest(paths.distIMAGES))
});
gulp.task('notify', function () {
notifier.notify({
title: 'Image Optimization',
message: 'Assests optimized successfully'
})
});
gulp.task('default', function (callback) {
runSequence('optimize', 'notify');
});