-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
73 lines (60 loc) · 1.76 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
"use strict";
const connect = require("gulp-connect");
const path = require("path");
const gulp = require("gulp");
const del = require("del");
const build = require("./tasks/build");
const buildPreview = require("./tasks/build-preview");
const format = require("./tasks/format");
const lintCss = require("./tasks/lint-css");
const lintJs = require("./tasks/lint-js");
const pack = require("./tasks/pack");
const preview = require("./tasks/preview");
const bundleName = "ui";
const buildDir = "build";
const previewSiteSrcDir = "preview-site-src";
const previewSiteDestDir = "public";
const srcDir = "src";
const destDir = path.join(previewSiteDestDir, "_");
const jsFiles = [
"gulpfile.js",
"tasks/**/*.js",
path.join(srcDir, "{helpers,js}/**/*.js"),
];
gulp.task("clean", function () {
return del(["./public/**", "./build/**"]);
});
gulp.task("lint:css", () => lintCss(`${srcDir}/css/**/*.css`));
gulp.task("lint:js", () => lintJs(jsFiles));
gulp.task("lint", gulp.parallel("lint:css", "lint:js"));
gulp.task("bundle", () => pack(destDir, buildDir, bundleName));
gulp.task("format", () => format(jsFiles));
gulp.task("build", () => build(srcDir, destDir));
gulp.task(
"build:preview",
gulp.series("build", () =>
buildPreview(
srcDir,
destDir,
previewSiteSrcDir,
previewSiteDestDir,
connect.reload
)
)
);
gulp.task(
"preview",
gulp.series("build:preview", () =>
preview(previewSiteDestDir, {
host: "0.0.0.0",
port: 5252,
livereload: process.env.LIVERELOAD === "true",
watch: {
src: [srcDir, previewSiteSrcDir],
onChange: () => gulp.start("build:preview"),
},
})
)
);
gulp.task("pack", gulp.series("clean", "lint", "build", "bundle"));
gulp.task("default", gulp.series("build"));