-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
38 lines (33 loc) · 880 Bytes
/
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
const { src, dest, series } = require("gulp");
const through = require("through2");
const rimraf = require("rimraf");
const reg1 =
/<link[^>]*?href\s*=\s*[""']?([^'"" >]+?)[ '""][^>]*?data-href\s*=\s*[""']?([^'"" >]+?)[ '""][^>]*?>/gi;
function clean(cb) {
rimraf("docs/**/*", (err) => {
if (err) {
console.log(err);
}
cb();
});
}
function copyHtml() {
return src(["packages/**/*.html"])
.pipe(
through.obj(function (file, enc, cb) {
let content = file.contents.toString();
content = content.replace(reg1, `<link rel="stylesheet" href="$2" />`);
file.contents = Buffer.from(content);
cb(null, file);
})
)
.pipe(dest("docs"));
}
function copyIndex() {
return src("README.md").pipe(dest("docs"));
}
module.exports = {
generateDoc: series(clean, copyHtml, copyIndex),
clean,
copyHtml,
};