-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
125 lines (107 loc) · 2.67 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
var gulp = require("gulp");
var pug = require("gulp-pug");
var stylus = require("gulp-stylus");
var rupture = require("rupture");
var data = require('gulp-data');
var browserSync = require("browser-sync");
var pathsView = [
"src/index.pug",
"!src/blocks/*.pug",
"!src/blocks/**/*.pug"
];
var pathsViewToWatch = [
"src/*.pug",
"src/**/*.pug"
];
var pathsStyles = [
"src/styles/index.styl"
];
var pathsStylesToWatch = [
"src/styles/*.styl",
"src/styles/**/*.styl"
];
var pathsScripts = [
"src/scripts/app.js",
"src/scripts/**/*.js"
];
var pathsScriptsToWatch = [
"src/scripts/*.js",
"src/scripts/**/*.js"
];
var pathVendor = [
"vendor/**"
];
var pathsVendorToWatch = [
"vendor/*",
"vendor/**/*",
];
var pathData = [
"src/*.json"
];
var taskPugSelf = function(){
return gulp.src(pathsView)
.pipe(data(function(file) {
return require("./src/books-schema.json");
}))
.pipe(pug({
pretty: true
}))
.pipe(gulp.dest("./public"));
};
gulp.task("view", function(){
return taskPugSelf();
});
var taskStylusSelf = function(){
return gulp.src(pathsStyles)
.pipe(stylus({
use:[rupture()]
}))
.pipe(gulp.dest("./public/styles"));
};
gulp.task("styles", function(){
return taskStylusSelf();
});
var taskScriptsSelf = function(){
return gulp.src(pathsScripts)
.pipe(gulp.dest("./public/scripts"));
};
gulp.task("scripts", function(){
return taskScriptsSelf();
});
gulp.task("data", function(){
return gulp.src(pathData)
.pipe(gulp.dest("./public/"));
});
var taskVendorSelf = function(){
return gulp.src(pathVendor)
.pipe(gulp.dest("./public/vendor"));
};
gulp.task("vendor", function(){
return taskVendorSelf();
});
gulp.task("watch", function(){
gulp.watch(pathsViewToWatch, function(){
taskPugSelf();
});
gulp.watch(pathsStylesToWatch, function(){
taskStylusSelf();
});
gulp.watch(pathsScriptsToWatch, function(){
taskScriptsSelf();
});
gulp.watch(pathsVendorToWatch, function(){
taskVendorSelf();
});
gulp.watch("./public/*.*").on("change", browserSync.reload);
gulp.watch("./public/**/*.*").on("change", browserSync.reload);
});
gulp.task("ServerBrowserSync", function(){
browserSync.init({
port: 8089,
server: {
baseDir: "./public/"
}
});
});
gulp.task("build", ["view", "styles", "scripts", "data", "vendor"]);
gulp.task("server", ["ServerBrowserSync", "watch"]);