This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (63 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
var browserSync = require("browser-sync").create();
var del = require("del");
var gulp = require("gulp");
var htmlhint = require("gulp-htmlhint");
var sass = require("gulp-sass");
var sassLint = require("gulp-sass-lint");
var sourcemaps = require("gulp-sourcemaps");
var util = require("gulp-util");
var paths = {
sources: {
application: "application/**/*",
html: ["src/*.html"],
scss: ["src/scss/**/*"]
},
entrypoints: {
scss: "src/scss/application.scss"
},
destinations: {
application: "application"
}
};
gulp.task("build", gulp.series(
cleanBuild,
gulp.parallel(lintHtml, lintScss),
gulp.parallel(buildHtml, buildCss)
));
gulp.task("default", gulp.series("build", watch));
function cleanBuild() {
return del([paths.destinations.application]);
}
function buildHtml() {
return gulp.src(paths.sources.html)
.pipe(gulp.dest(paths.destinations.application));
}
function lintScss() {
return gulp.src(paths.entrypoints.scss)
.pipe(sassLint())
.pipe(sassLint.format())
.pipe(sassLint.failOnError());
}
function buildCss() {
return gulp.src(paths.entrypoints.scss)
.pipe(sourcemaps.init())
.pipe(sass().on("error", sass.logError))
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest(paths.destinations.application));
}
function lintHtml() {
return gulp.src(paths.sources.html)
.pipe(htmlhint())
.pipe(htmlhint.failReporter());
}
function reload(done) {
browserSync.reload();
done();
}
function watch() {
browserSync.init({
server: "./application"
});
gulp.watch(paths.sources.html, gulp.series(lintHtml, buildHtml, reload));
gulp.watch(paths.sources.scss, gulp.series(lintScss, buildCss, reload));
}