-
Notifications
You must be signed in to change notification settings - Fork 173
/
gulpfile.mjs
136 lines (126 loc) · 2.99 KB
/
gulpfile.mjs
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
128
129
130
131
132
133
134
135
136
/* Imports */
import gulp from "gulp";
const { series, parallel, src, dest, task } = gulp;
import plumber from "gulp-plumber";
import concat from "gulp-concat";
import htmlmin from "gulp-htmlmin";
import cleancss from "gulp-clean-css";
import terser from "gulp-terser";
import gzip from "gulp-gzip";
import { deleteAsync } from "del";
import markdown from "gulp-markdown-github-style";
import rename from "gulp-rename";
import using from "gulp-using";
/* HTML Task */
gulp.task("html", function () {
return gulp
.src(["html/*.html"])
.pipe(using())
.pipe(plumber())
.pipe(
htmlmin({
collapseWhitespace: true,
removeComments: true,
minifyCSS: true,
minifyJS: true,
})
)
.pipe(gzip())
.pipe(gulp.dest("data/www"));
});
/* CSS Task */
gulp.task("css", function () {
return gulp
.src(["html/css/*.css"])
.pipe(plumber())
.pipe(using())
.pipe(concat("esps.css"))
.pipe(cleancss())
.pipe(gzip())
.pipe(gulp.dest("data/www"));
});
/* JavaScript Task */
gulp.task("js", function () {
return gulp
.src([
"html/js/jquery-*.js",
"html/js/bootstrap.js",
"html/js/jqColorPicker.js",
"html/js/dropzone.js",
"html/js/FileSaver.js",
"html/js/jquery.cookie.js",
"html/script.js",
])
.pipe(plumber())
.pipe(using())
.pipe(concat("esps.js"))
.pipe(
terser({ toplevel: true })
) /* comment out this line to debug the script file */
.pipe(gzip())
.pipe(using())
.pipe(gulp.dest("data/www"));
});
/* json Task */
gulp.task("json", function () {
return gulp
.src("html/*.json")
.pipe(using())
.pipe(plumber())
.pipe(gulp.dest("data"));
});
/* Image Task */
gulp.task("image", function () {
return gulp
.src(["html/**/*.png", "html/**/*.ico"])
.pipe(using())
.pipe(plumber())
.pipe(gulp.dest("data/www"));
});
/* Clean Task */
gulp.task("clean", function () {
return deleteAsync(["data/www/*"]);
});
/* Markdown to HTML Task */
gulp.task("md", function (done) {
gulp
.src("README.md")
.pipe(plumber())
.pipe(rename("ESPixelStick.html"))
.pipe(markdown())
.pipe(gulp.dest("dist"));
gulp
.src("Changelog.md")
.pipe(plumber())
.pipe(rename("Changelog.html"))
.pipe(markdown())
.pipe(gulp.dest("dist"));
gulp
.src("dist/README.md")
.pipe(plumber())
.pipe(rename("README.html"))
.pipe(markdown())
.pipe(gulp.dest("dist"));
done();
});
/* CI specific stuff */
gulp.task("ci", function (done) {
gulp
.src([".ci/warning.md", "dist/README.md"])
.pipe(plumber())
.pipe(concat("README.html"))
.pipe(markdown())
.pipe(gulp.dest("dist"));
done();
});
/* Watch Task */
gulp.task("watch", function () {
gulp.watch("html/*.html", gulp.series("html"));
gulp.watch("html/**/*.css", gulp.series("css"));
gulp.watch("html/**/*.js", gulp.series("js"));
});
/* Default Task */
gulp.task(
"default",
gulp.series(["clean", "html", "css", "js", "image", "json"])
);