-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
60 lines (53 loc) · 1.51 KB
/
gulpfile.js
File metadata and controls
60 lines (53 loc) · 1.51 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
var gulp = require("gulp")
, util = require("gulp-util")
, conn = require("gulp-connect")
, sass = require("gulp-compass")
, del = require("gulp-clean-dest")
;
// sources
var appRoot = "dev/"
, srcRoot = "src/"
, prdRoot = "/Volumes/Macintosh HD-1/Library/WebServer/Documents/"
, htmlSrc = appRoot + "**/*.html"
, sassSrc = srcRoot + "sass/"
;
gulp.task("connect", function() {
// I create a Web server which I will use to live reload the page as changes occur.
conn.server(
{ "root": appRoot
, "livereload": true
})
});
gulp.task("html", function() {
// I handle html files
return gulp.src(htmlSrc)
.pipe(conn.reload());
});
gulp.task("compass", function() {
// I transpile SASS files into CSS
return gulp.src(sassSrc + "style.scss")
.pipe(sass(
{ "sass": sassSrc
, "style": "expanded"
, "comments": true
})
.on("error", util.log)
)
.pipe(gulp.dest(appRoot + "css"))
.pipe(conn.reload())
.pipe(del("css")) // Deleting "css/style.css" allows style to be changed from one run to the next
});
gulp.task("watch", function() {
// I watch for file changes and run tasks
gulp.watch(htmlSrc, ["html"]);
gulp.watch(sassSrc + "**/*.scss", ["compass"]);
});
gulp.task("default", ["connect", "html", "compass", "watch"], function() {
util.log("- I loaded all above tasks ;)");
});
gulp.task("deploy", function() {
// I promote the code to PRD
return gulp.src(appRoot + "**/*.*")
.pipe(del(prdRoot))
.pipe(gulp.dest(prdRoot));
});