/
gulpfile.js
61 lines (55 loc) · 1.72 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
var gulp = require("gulp");
var plugins = require("gulp-load-plugins")();
var tinyLr = require("tiny-lr");
var static = require("node-static");
var http = require("http");
var lrServer = tinyLr();
var dvServer = http.createServer(function (req, res) {
var stServer = new static.Server("./demo", {cache: false});
req.on("end", function () {
stServer.serve(req, res);
});
req.resume();
});
gulp.task("styles", function () {
gulp.src("styles/sprinkle.scss")
.pipe(plugins.sass())
.pipe(plugins.autoprefixer("last 2 version"))
.pipe(plugins.rename("sprinkle.css"))
.pipe(gulp.dest("dist/"))
.pipe(plugins.minifyCss())
.pipe(plugins.rename("sprinkle.min.css"))
.pipe(gulp.dest("dist/"))
.pipe(plugins.livereload(lrServer));
});
gulp.task("scripts", function () {
gulp.src("scripts/sprinkle.js")
.pipe(plugins.ngmin())
.pipe(gulp.dest("dist/"));
});
gulp.task("templates", function () {
gulp.src("templates/**/*.html")
.pipe(plugins.ngHtml2js({
moduleName: "mnd.sprinkle",
prefix: "templates/"
}))
.pipe(plugins.concat("sprinkle.template-cache.js"))
.pipe(gulp.dest("dist/"));
});
gulp.task("final", function () {
gulp.src(["dist/sprinkle.js", "dist/sprinkle.template-cache.js"])
.pipe(plugins.concat("sprinkle-tpls.js"))
.pipe(gulp.dest("dist/"))
.pipe(plugins.uglify())
.pipe(plugins.rename("sprinkle-tpls.min.js"))
.pipe(gulp.dest("dist/"))
.pipe(plugins.livereload(lrServer));
});
gulp.task("default", function () {
dvServer.listen(8080);
lrServer.listen(35729);
gulp.watch("styles/sprinkle.scss", ["styles"]);
gulp.watch("scripts/sprinkle.js", ["scripts"]);
gulp.watch("templates/**/*.html", ["templates"]);
gulp.watch(["dist/sprinkle.template-cache.js", "dist/sprinkle.js"], ["final"]);
});