-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
54 lines (45 loc) · 1.27 KB
/
gulpfile.js
File metadata and controls
54 lines (45 loc) · 1.27 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
var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
var clean = require('gulp-clean');
var rename = require ("gulp-rename");
var imageResize = require('gulp-image-resize');
var run = require('run-sequence');
gulp.task('imagemin', function () {
return gulp.src('src/**/*.{png,jpg,svg}')
.pipe(imagemin([
imagemin.optipng({optimizationLevel: 3}),
imagemin.jpegtran({progressive: true}),
imagemin.svgo()
]))
.pipe(gulp.dest('build'))
});
var counterNameResize = 1;
gulp.task('resize', function () {
gulp.src('src/**/*.{png,jpg,svg}')
.pipe(imageResize({
width : 40,
height : 325,
crop: true
}))
.pipe(rename(function (path) {
path.basename = counterNameResize;
counterNameResize++;
}))
.pipe(gulp.dest('build/crop-img'));
});
var counterNameNew = 1;
gulp.task('new-name', function () {
gulp.src('src/**/*.{png,jpg,svg}')
.pipe(rename(function (path) {
path.basename = counterNameNew;
counterNameNew++;
}))
.pipe(gulp.dest('build/big-img'));
});
gulp.task('clean', function () {
return gulp.src('build')
.pipe(clean())
});
gulp.task('build', function (callback) {
run('clean', 'resize', 'new-name', callback);
});