-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
157 lines (135 loc) · 3.59 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
"use strict";
const merge = require("merge-stream");
const csso = require("gulp-csso");
const del = require("del");
const gulp = require("gulp");
const htmlmin = require("gulp-htmlmin");
const sass = require("gulp-sass")(require("sass"));
const uglify = require("gulp-uglify-es").default;
const connect = require("gulp-connect");
const replace = require("gulp-replace");
const svgs = [
"solid/globe",
"brands/android",
"brands/windows",
"brands/linux",
"regular/handshake",
"regular/copyright",
];
// CLEAN
gulp.task("clean", () => {
return del(["dist", "serve"]);
});
// BUILD
gulp.task("build:style", () => {
return gulp.src("src/asset/**/*.scss")
// Compile SASS files
.pipe(sass().on("error", sass.logError))
// Minify the file
.pipe(csso())
// Output
.pipe(gulp.dest("dist/asset"));
});
gulp.task("build:script", () => {
return gulp.src("src/asset/**/*.js")
// Minify the file
.pipe(uglify())
// Output
.pipe(gulp.dest("dist/asset"));
});
gulp.task("build:html", () => {
return gulp.src(["src/**/*.html"])
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true,
}))
.pipe(replace("node_modules/@fortawesome/fontawesome-free", "asset"))
.pipe(replace("node_modules/bootstrap/dist/js", "asset"))
.pipe(replace("node_modules/jquery/dist", "asset"))
.pipe(gulp.dest("dist"));
});
gulp.task("build:asset", () => {
return merge(
gulp.src("src/asset/*/**/*")
.pipe(gulp.dest("dist/asset/")),
gulp.src(["node_modules/@fortawesome/fontawesome-free/svgs/{" + svgs.join() + "}.svg"])
.pipe(gulp.dest("dist/asset/svgs")),
);
});
gulp.task("build:node", () => {
return gulp.src([
"node_modules/bootstrap/dist/js/bootstrap.bundle.js",
"node_modules/jquery/dist/jquery.slim.js",
])
.pipe(uglify())
.pipe(gulp.dest("dist/asset/"));
});
gulp.task("build", gulp.series(
"clean",
"build:style",
"build:script",
"build:html",
"build:asset",
"build:node",
));
// SERVE
gulp.task("serve:html", () => {
return gulp.src(["src/**/*.html"])
.pipe(replace("node_modules/@fortawesome/fontawesome-free", "asset"))
.pipe(replace("node_modules/bootstrap/dist/js", "asset"))
.pipe(replace("node_modules/jquery/dist", "asset"))
.pipe(gulp.dest("serve"));
});
gulp.task("serve:style", () => {
return gulp.src("src/asset/style.scss")
.pipe(sass().on("error", sass.logError))
.pipe(gulp.dest("serve/asset/"));
});
gulp.task("serve:asset", () => {
return merge(
gulp.src(["src/asset/*/**/*", "src/asset/*.js"])
.pipe(gulp.dest("serve/asset/")),
gulp.src(["node_modules/@fortawesome/fontawesome-free/svgs/{" + svgs.join() + "}.svg"])
.pipe(gulp.dest("serve/asset/svgs")),
);
});
gulp.task("serve:node", () => {
return gulp.src([
"node_modules/bootstrap/dist/js/bootstrap.bundle.js",
"node_modules/jquery/dist/jquery.slim.js",
]).pipe(gulp.dest("serve/asset/"));
});
gulp.task("serve:reload", () => {
return gulp.src("serve").pipe(connect.reload());
});
gulp.task("serve:watch", async () => {
return gulp.watch("src/**/*", gulp.series(
"clean",
"serve:html",
"serve:node",
"serve:style",
"serve:asset",
"serve:reload",
));
});
gulp.task("serve:connect", async () => {
connect.server({
port: 4000,
root: "serve",
livereload: true,
});
});
gulp.task("serve", gulp.series(
"clean",
"serve:html",
"serve:asset",
"serve:node",
"serve:style",
"serve:reload",
"serve:connect",
"serve:watch",
));
// DEFAULT
gulp.task("default", async () => {
console.log("Check README.md to see development commands.");
});