-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
executable file
·74 lines (65 loc) · 2.23 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
var gulp = require("gulp");
var stylus = require("gulp-stylus");
var templateCache = require("gulp-angular-templatecache");
var del = require("del");
var concat = require("gulp-concat");
var streamqueue = require("streamqueue");
var connect = require("gulp-connect");
gulp.task("clean", function() {
return del.sync("dist/**/*", function(err, paths) {
console.log("Deleted fils/folders:\n", paths.join("\n"));
});
});
gulp.task("gen-style", function() {
return gulp.src("./src/css/keyboard.styl")
.pipe(stylus({compress: true}))
.pipe(gulp.dest("./dist/css"))
.pipe(connect.reload());
});
gulp.task("gen-demo-style", function() {
return gulp.src("./example/css/**/*.styl")
.pipe(stylus({compress: false}))
.pipe(gulp.dest("./example/css"))
.pipe(connect.reload());
});
gulp.task("gen-scripts", function() {
return streamqueue({objectMode: true}, gulp.src(["./src/js/src/**/*.js"]), getTemplateStream())
.pipe(concat("angular-mobile-keyboard.js"))
.pipe(gulp.dest("./dist/js/"))
.pipe(connect.reload());
});
gulp.task("copy-images", function() {
return gulp.src("./src/images/**/*")
.pipe(gulp.dest("./dist/images/"))
.pipe(connect.reload());
});
gulp.task("auto-gen", function() {
var options = {
start: true
};
gulp.watch("./src/css/**/*.styl", ["gen-style"]);
//auto gen example basic style
gulp.watch("./example/css/**/*.styl",["gen-demo-style"]);
//auto gen scripts
gulp.watch(["./src/js/src/**.js", "./src/template/**/*.html"], ["gen-scripts"]);
//auto copy images
gulp.watch("./src/images/**/*",["copy-images"]);
});
gulp.task("connect", function(){
connect.server({
livereload: true
});
});
function getTemplateStream() {
var options = {
module: "ngMobileKeyboard",
filename: "angular-mobile-keyboard.js",
transformUrl: function(url) {
return "template/" + url;
}
};
return gulp.src("./src/template/**/*.html")
.pipe(templateCache(options));
}
gulp.task("default", ["clean", "gen-style", "gen-scripts", "copy-images"]);
gulp.task("dev", ["clean", "gen-style", "gen-scripts", "copy-images", "connect", "auto-gen"]);