This repository has been archived by the owner on Dec 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
85 lines (72 loc) · 2.02 KB
/
gulpfile.babel.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
import fs from "fs";
import {spawn} from "child_process";
import gulp from "gulp";
import babel from "gulp-babel";
import clean from "gulp-clean";
import stylus from "gulp-stylus";
import postcss from "gulp-postcss";
import autoprefixer from "autoprefixer";
import cssnano from "cssnano";
import mqpacker from "css-mqpacker";
// google site verification
const ghash = "google9ab7bf08387cc375";
const cleanup = () =>
gulp
.src(["build", "modules/comps/Illuminate.css"], {
force: true,
read: false,
allowEmpty: true
})
.pipe(clean());
const stylusbuild = () =>
gulp
.src("assets/stylus/Illuminate.styl")
.pipe(
stylus({
compress: true
})
)
.pipe(postcss([autoprefixer, cssnano, mqpacker]))
.pipe(gulp.dest("modules/comps/"));
const styluswatch = () => gulp.watch("assets/stylus/**", stylusbuild);
const extasset = (repo, file) =>
gulp.src(`node_modules/${repo}/${file}`).pipe(gulp.dest("build/assets/js"));
const assets = (done) => {
extasset("vanilla-lazyload", "dist/**");
extasset("smooth-scroll", "dist/**");
return done();
};
const nextjs = () =>
gulp
.src("assets/js/**")
.pipe(babel())
.pipe(gulp.dest("build/assets/js"));
const nextjswatch = () => gulp.watch("assets/js/**", nextjs);
const personal = (done) => {
!fs.existsSync("build") && fs.mkdirSync("build");
// for github pages
fs.writeFile("build/.nojekyll", "", done);
fs.writeFile(
`build/${ghash}.html`,
`google-site-verification: ${ghash}.html`,
done
);
};
const prepareAssets = gulp.parallel(stylusbuild, personal, assets, nextjs);
const eleventy = (options = "") => {
let cmd = (done) =>
spawn("eleventy", options.split(), {stdio: "inherit"}).on("close", (code) =>
done(code)
);
cmd.displayName = "eleventy" + options;
return cmd;
};
gulp.task(
"serve",
gulp.series(
cleanup,
prepareAssets,
gulp.parallel(styluswatch, nextjswatch, eleventy("--serve"))
)
);
gulp.task("default", gulp.series(cleanup, prepareAssets, eleventy()));