-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
127 lines (111 loc) · 3 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
const { series, parallel, src, dest } = require('gulp')
const rm = require('del')
const rename = require('gulp-rename')
const minifyJS = require('gulp-terser')
const minifyJSON = require('gulp-jsonminify')
const minifyCSS = require('gulp-clean-css')
const minifyHTML = require('gulp-html-minifier-terser')
const SOURCE_FOLDER = 'src/'
const BUILD_FOLDER = 'docs/'
const FPATHS = {
js: {
src: SOURCE_FOLDER + 'assets/js/**/*.js',
src_min: SOURCE_FOLDER + 'assets/js/**/*.min.js',
dest: BUILD_FOLDER + 'assets/js/'
},
css: {
src: SOURCE_FOLDER + 'assets/css/**/*.css',
src_min: [
SOURCE_FOLDER + 'assets/css/**/*.min.css',
SOURCE_FOLDER + 'assets/css/**/*.eot',
SOURCE_FOLDER + 'assets/css/**/*.svg',
SOURCE_FOLDER + 'assets/css/**/*.ttf',
SOURCE_FOLDER + 'assets/css/**/*.woff',
SOURCE_FOLDER + 'assets/css/**/*.woff2'
],
dest: BUILD_FOLDER + 'assets/css/'
},
html: {
src: SOURCE_FOLDER + '*.html',
dest: BUILD_FOLDER
},
icons: {
src: SOURCE_FOLDER + 'assets/icons/**/*.png',
dest: BUILD_FOLDER + 'assets/icons/'
},
logos: {
src: [
SOURCE_FOLDER + 'assets/logos/**/*.png',
SOURCE_FOLDER + "assets/logos/**/*.svg"
],
dest: BUILD_FOLDER + 'assets/logos/'
},
locales: {
src: SOURCE_FOLDER + 'assets/i18n/*.json',
dest: BUILD_FOLDER + 'assets/i18n/'
},
manifest: {
src: SOURCE_FOLDER + 'bhackers.webmanifest',
dest: BUILD_FOLDER
},
cname: {
src: SOURCE_FOLDER + 'CNAME.txt',
dest: BUILD_FOLDER
}
}
function jsTask () {
return src(FPATHS.js.src)
.pipe(minifyJS())
.pipe(dest(FPATHS.js.dest))
}
function jsMinTask () {
return src(FPATHS.js.src_min)
.pipe(dest(FPATHS.js.dest))
}
function cssTask () {
return src(FPATHS.css.src)
.pipe(minifyCSS())
.pipe(dest(FPATHS.css.dest))
}
function cssMinTask () {
return src(FPATHS.css.src_min)
.pipe(dest(FPATHS.css.dest))
}
function htmlTask () {
return src(FPATHS.html.src)
.pipe(minifyHTML({
removeComments: true,
collapseWhitespace: true
}))
.pipe(dest(FPATHS.html.dest))
}
function iconsTask () {
return src(FPATHS.icons.src)
.pipe(dest(FPATHS.icons.dest))
}
function logosTask () {
return src(FPATHS.logos.src)
.pipe(dest(FPATHS.logos.dest))
}
function localesTask () {
return src(FPATHS.locales.src)
.pipe(minifyJSON())
.pipe(dest(FPATHS.locales.dest))
}
function manifestTask () {
return src(FPATHS.manifest.src)
.pipe(minifyJSON())
.pipe(rename('bhackers.webmanifest'))
.pipe(dest(FPATHS.manifest.dest))
}
function cnameTask () {
return src(FPATHS.cname.src)
.pipe(rename('CNAME'))
.pipe(dest(FPATHS.cname.dest))
}
function cleanBuildAll () {
return rm([BUILD_FOLDER + '*', '!' + BUILD_FOLDER + 'CNAME'])
}
const DEFAULT_BUILD_TASKS = parallel(jsTask, jsMinTask, cssTask, cssMinTask, htmlTask, iconsTask, logosTask, localesTask, manifestTask, cnameTask)
exports.clean = cleanBuildAll
exports.default = series(cleanBuildAll, DEFAULT_BUILD_TASKS)