-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
82 lines (66 loc) · 1.78 KB
/
gulpfile.js
File metadata and controls
82 lines (66 loc) · 1.78 KB
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
const gulp = require("gulp");
const sass = require("gulp-sass");
const gutil = require("gulp-util");
const plumber = require("gulp-plumber");
const chalk = require("chalk");
const runSequence = require("run-sequence");
const del = require("del");
const sourceFolder = "src";
const distFolder = "dist";
const PATH = {
SRC: {
APP: sourceFolder,
HTML: sourceFolder + "/**/*.html",
ASSETS: sourceFolder + "/assets/*",
STYLE: sourceFolder + "/style/*.scss",
},
DIST: {
APP: distFolder,
HTML: distFolder + "/",
ASSETS: distFolder + "/assets/",
STYLE: distFolder + "/style/",
},
};
gulp.task("clean", function () {
return del([PATH.DIST.APP]);
});
gulp.task("html", function () {
return gulp.src(PATH.SRC.HTML).pipe(gulp.dest(PATH.DIST.HTML));
});
gulp.task("assets", function () {
return gulp.src(PATH.SRC.ASSETS).pipe(gulp.dest(PATH.DIST.ASSETS));
});
gulp.task("sass", function () {
return gulp
.src(PATH.SRC.STYLE)
.pipe(
plumber({
errorHandler: reportError,
})
)
.pipe(sass())
.pipe(gulp.dest(PATH.DIST.STYLE));
});
var reportError = function (error) {
gutil.beep();
var report = "",
chalk = gutil.colors.white.bgRed;
report += chalk("TASK:") + " [" + error.plugin + "]\n";
report += chalk("PROB:") + " " + error.message + "\n";
if (error.lineNumber) {
report += chalk("LINE:") + " " + error.lineNumber + "\n";
}
if (error.fileName) {
report += chalk("FILE:") + " " + error.fileName + "\n";
}
console.error(report);
this.emit("end");
};
gulp.task("watch", function () {
gulp.watch(PATH.SRC.HTML, ["html"]);
gulp.watch(PATH.SRC.ASSETS, ["assets"]);
gulp.watch(PATH.SRC.STYLE, ["sass"]);
});
gulp.task("default", function () {
runSequence("clean", "html", "assets", "sass");
});