-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
113 lines (94 loc) · 2.25 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
var gulp = require("gulp");
var tinyLr = require('tiny-lr');
var express = require ("express");
var concat = require("gulp-concat");
var files = require("./files.json");
var runSequence = require('run-sequence');
var ngHtml2Js = require("gulp-ng-html2js");
var minifyHtml = require("gulp-minify-html");
var del = require("del");
var lr;
var EXPRESS_PORT = 8000;
var EXPRESS_ROOT = __dirname + "/dist";
var LIVERELOAD_PORT = 35729;
function startLiveReload(){
lr = tinyLr();
lr.listen(LIVERELOAD_PORT);
}
function startServer(){
var app = express();
console.log (EXPRESS_ROOT);
app.use(express.static(EXPRESS_ROOT));
app.listen(EXPRESS_PORT);
}
function notifyLivereload(event) {
runSequence(["clean",
"styles",
"libs",
"src",
"fonts"
], function(){
var fileName = require("path").relative(EXPRESS_ROOT, event.path);
lr.changed({
body: {
files: [fileName]
}
});
});
}
gulp.task("serve", function(){
startServer();
});
gulp.task("clean", function() {
return del("dist/**");
});
gulp.task("libs", function() {
gulp.src(files.libs)
.pipe(concat("libs.js"))
.pipe(gulp.dest("./dist/"))
});
gulp.task("styles", function() {
gulp.src(files.styles)
.pipe(concat("app.css"))
.pipe(gulp.dest("./dist/"))
});
gulp.task("images", function() {
gulp.src(files.images)
.pipe(gulp.dest("./dist"))
});
gulp.task("fonts", function() {
gulp.src(files.fonts)
.pipe(gulp.dest("./dist/fonts"))
});
gulp.task("json", function() {
gulp.src(files.json)
.pipe(gulp.dest("./dist/"))
});
gulp.task("html", function() {
gulp.src("src/index.html")
.pipe(gulp.dest("./dist"));
gulp.src("src/timezone.html")
.pipe(gulp.dest("./dist"));
gulp.src(files.html)
.pipe(minifyHtml({
empty: true,
spare: true,
quotes: true
}))
.pipe(ngHtml2Js({
moduleName: "html"
}))
.pipe(concat("html.min.js"))
.pipe(gulp.dest("./dist"))
});
gulp.task("src", ["html", "images"], function() {
gulp.src(files.src)
.pipe(concat("src.js"))
.pipe(gulp.dest("./dist"))
});
gulp.task("watch", function(){
startServer();
startLiveReload();
gulp.watch(["src/**", "src/**/**"], notifyLivereload);
});
gulp.task("default", ["clean", "styles", "libs", "src", "fonts", "json"]);