-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathGulpfile.js
64 lines (54 loc) · 1.64 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
const { dest, parallel, series, src, watch } = require("gulp");
const connect = require("gulp-connect");
const del = require("delete");
const less = require("gulp-less");
const sass = require("gulp-sass")(require("sass"));
const sourcemaps = require("gulp-sourcemaps");
const ts = require("gulp-typescript");
const DISTDIR = "./dist";
const SRCDIR = "./src";
const buildAssets = () =>
src(`${SRCDIR}/*.{css,dart,html,ico,js,map,mjs,dict}`)
.pipe(dest(`${DISTDIR}`))
.pipe(connect.reload());
const buildLESS = () => {
return src(`${SRCDIR}/*.less`)
.pipe(sourcemaps.init())
.pipe(less())
.pipe(sourcemaps.write("./"))
.pipe(dest(`${DISTDIR}`))
.pipe(connect.reload());
};
const buildSASS = () => {
return src(`${SRCDIR}/*.{sass,scss}`)
.pipe(sourcemaps.init())
.pipe(sass().on("error", sass.logError))
.pipe(sourcemaps.write("./"))
.pipe(dest(`${DISTDIR}`))
.pipe(connect.reload());
};
const buildStyles = parallel(buildLESS, buildSASS);
const buildTypeScript = () => {
return src(`${SRCDIR}/*.ts`)
.pipe(sourcemaps.init())
.pipe(ts({}))
.pipe(sourcemaps.write("./"))
.pipe(dest(`${DISTDIR}`))
.pipe(connect.reload());
};
const copyHeaders = () =>
src(`${SRCDIR}/_headers`)
.pipe(dest(`${DISTDIR}`))
.pipe(connect.reload());
const build = parallel(buildAssets, buildStyles, buildTypeScript, copyHeaders);
const clean = cb => del([`${DISTDIR}`], cb);
exports.build = build;
exports.clean = clean;
exports.default = async () => {
await watch(`${SRCDIR}`, { ignoreInitial: false }, build);
await connect.server({
root: `${DISTDIR}`,
livereload: true,
port: 8000
});
};