-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
93 lines (78 loc) · 2.18 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
var gulp = require('gulp'),
shell = require('gulp-shell'),
purgecss = require('gulp-purgecss'),
merge = require('merge-stream'),
babel = require('gulp-babel'),
webp = require('gulp-webp');
image = require('gulp-image');
gulp.task('serve', function() {
return gulp.src('index.html', { read: false })
.pipe(shell([
'bundle exec jekyll serve --livereload'
]));
});
gulp.task('jekyll-build', function() {
return gulp.src('index.html', { read: false })
.pipe(shell([
'bundle exec jekyll build'
]));
});
const rootImgFolder = '_site/assets/images';
var imgFolders = [`${rootImgFolder}/work/`, `${rootImgFolder}/post/`];
gulp.task('compressImages', () => {
var _compressImages = imgFolders.map((element) => {
return gulp.src(element + '*.{jpg,png}')
.pipe(image({
pngquant: true,
optipng: false,
zopflipng: true,
jpegRecompress: false,
mozjpeg: true,
guetzli: false,
gifsicle: true,
svgo: true,
concurrent: 10,
quiet: true // defaults to false
}))
.pipe(gulp.dest(element));
});
return merge(_compressImages);
});
gulp.task('convertToWebp', () => {
var _convertToWebp = imgFolders.map((element) => {
return gulp.src(element + '*.{jpg,png}')
.pipe(webp({
quality: 50,
sns: 0
}))
.pipe(gulp.dest(element));
});
return merge(_convertToWebp);
});
gulp.task('images', gulp.series('compressImages', 'convertToWebp', function (done) {
done();
}));
gulp.task('purgecss', () => {
return gulp
.src('_site/assets/css/*.css')
.pipe(
purgecss({
content: ['_site/**/*.html', '_site/**/*.js' ]
})
)
.pipe(gulp.dest('_site/assets/css') )
});
gulp.task("babel", function () {
return gulp.src("_site/assets/js/app.js")
.pipe(babel({
presets: ['@babel/preset-env']
}))
.pipe(gulp.dest("_site/assets/js/"));
});
gulp.task('build', gulp.series('jekyll-build', 'images', 'purgecss', 'babel', function (done) {
done();
}));
//TODO IMPLEMENT MINIFY CSS AND JS
//TODO STILL NEED TO RESIZE IMAGES -- TOO BIG
//TODO USE GULP-RESPONSIVE TO BUILD SRCSET
//TODO ADD APPS AND TOOLS