-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
100 lines (73 loc) · 2.16 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
const gulp = require("gulp");
const {parallel} = require("gulp");
const htmlmin = require("gulp-htmlmin");
const imagemin = require("gulp-imagemin");
const jsonminify = require('gulp-jsonminify');
const del = require('del');
//Just to copy/update HTML view components from src to dist
function syncViews(){
return gulp.src("src/views/*.html")
.pipe(gulp.dest("dist/views"));
}
function syncContent(){
return gulp.src("src/content/*.json")
.pipe(gulp.dest("dist/content"));
}
function syncDownloadables(){
return gulp.src("src/downloadables/**/*")
.pipe(gulp.dest("dist/downloadables"));
}
//Copy & minify HTML view components from src to dist
function buildViews(){
return gulp.src("src/views/*.html")
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest("dist/views"));
}
function buildContent(){
return gulp.src("src/content/*.json")
.pipe(jsonminify())
.pipe(gulp.dest("dist/content"));
}
//Optimise & copy image resources to dist
function syncImages(){
return gulp.src("src/images/**/*")
.pipe(imagemin())
.pipe(gulp.dest("dist/images"));
}
//Clean Folders
function cleanViews(){
return del(["dist/views/"]);
}
function cleanImages(){
return del(["dist/images/"]);
}
function cleanContent(){
return del(["dist/content/"]);
}
function cleanAll(){
return del(["dist/"]);
}
//Watch Folders
function watchHTML(){
return gulp.watch("src/views/*.html", syncViews);
}
function watchContent(){
return gulp.watch("src/content/*.json", syncContent);
}
function watchImages(){
return gulp.watch("src/images/**/*", syncImages);
}
function watchDownloadables(){
return gulp.watch("src/downloadables/**/*", syncDownloadables);
}
exports.syncViews = syncViews;
exports.syncContent = syncContent;
exports.syncImages = syncImages;
exports.syncDownloadables = syncDownloadables;
exports.cleanViews = cleanViews;
exports.cleanContent = cleanContent;
exports.cleanImages = cleanImages;
exports.cleanAll = cleanAll;
exports.buildViews = buildViews;
exports.buildContent = buildContent;
exports.default = parallel(watchHTML,watchImages,watchContent,watchDownloadables);