-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
95 lines (83 loc) · 2.04 KB
/
gulpfile.js
File metadata and controls
95 lines (83 loc) · 2.04 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
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
91
92
93
94
95
const gulp = require('gulp')
const htmlmin = require('gulp-htmlmin')
const cleanCSS = require('gulp-clean-css')
const terser = require('gulp-terser')
const imagemin = require('gulp-imagemin')
const imageResize = require('gulp-image-resize')
const ghPages = require('gulp-gh-pages')
const merge = require('merge-stream')
const deployOptions = {
branch: 'master'
}
gulp.task('html', () => {
return gulp
.src('index.html')
.pipe(htmlmin({
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeComments: true,
}))
.pipe(gulp.dest('./dist'))
})
gulp.task('css', () => {
return gulp
.src('static/styles/*.css')
.pipe(cleanCSS())
.pipe(gulp.dest('./dist/static/styles'))
})
gulp.task('js', () => {
return gulp
.src('static/scripts/*.js')
.pipe(terser())
.pipe(gulp.dest('./dist/static/scripts'))
})
gulp.task('img', () => {
const cfg = {
jpg: [ '.' ],
png: [ '.', 'coorganizers', 'courses', 'sponsors' ],
svg: [ 'courses' ]
}
const images = Object.entries(cfg).map(([ext, path]) => {
return path.map((name) => {
return gulp
.src(`static/images/${name}/*.${ext}`)
.pipe(imagemin([
imagemin.optipng(),
imagemin.svgo(),
imagemin.mozjpeg({
quality: 85
})
]), {
silent: true
})
.pipe(gulp.dest(`dist/static/images/${name}`))
})
})
const jpg = gulp
.src('static/images/clubs/*.jpg')
.pipe(imageResize({
width: 64,
height: 64
}))
.pipe(imagemin([
imagemin.mozjpeg({
quality: 85
})
]), {
silent: true
})
.pipe(gulp.dest('dist/static/images/clubs'))
return merge(images, jpg)
})
gulp.task('misc', () => {
const favicons = gulp
.src('static/favicon/**')
.pipe(gulp.dest('dist/static/favicon'))
return merge(favicons)
})
gulp.task('deploy', () => {
return gulp
.src('./dist/**/*')
.pipe(ghPages(deployOptions))
})
gulp.task('default', gulp.parallel('html', 'css', 'js', 'img', 'misc'))