forked from up1/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
62 lines (53 loc) · 1.55 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
53
54
55
56
57
58
59
60
61
62
var gulp = require('gulp'),
autoprefixer = require('autoprefixer'),
folders = require('gulp-folders-4x'),
imagemin = require('gulp-imagemin'),
imageResize = require('gulp-image-resize'),
jsonlint = require('gulp-jsonlint'),
path = require('path'),
postcss = require('gulp-postcss');
var site = '/site/';
gulp.task('css', folders(site, function(folder) {
var processors = [
autoprefixer({
})
];
return gulp.src(path.join(site, folder, 'assets', 'css', '*.css'))
.pipe(postcss(processors))
.pipe(gulp.dest(path.join(site, 'assets', 'css')));
}));
gulp.task('img:resize', folders(site, function(folder) {
var paths = [
path.join(site, folder, 'assets', 'img', '*.*'),
path.join(site, folder, 'images', '*.*'),
path.join(site, folder, 'images', '**', '*.*')
];
return gulp.src(paths)
.pipe(imageResize({
width: 1024,
upscale : false
}))
.pipe(gulp.dest(path.join(site, 'images')));
}));
gulp.task('img:minify', gulp.series('img:resize', folders(site, function(folder) {
var paths = [
path.join(site, folder, 'assets', 'img', '*.*'),
path.join(site, folder, 'images', '*.*'),
path.join(site, folder, 'images', '**', '*.*')
];
return gulp.src(paths)
.pipe(imagemin({
progressive: true,
svgoPlugins: [{
removeViewBox: false
}],
}))
.pipe(gulp.dest(path.join(site, 'images')));
})));
gulp.task('jsonlint', function() {
return gulp.src('./*.json')
.pipe(jsonlint())
.pipe(jsonlint.failAfterError());
});
gulp.task('post-process', gulp.parallel('css', 'img:minify'));
gulp.task('lint', gulp.series('jsonlint'));