-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
93 lines (76 loc) · 2.37 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
const conf = require("./gulp/config");
const gulp = require("gulp");
const concat = require("gulp-concat");
const del = require('del');
const watch = require('gulp-watch');
const print = require('gulp-print');
const strip = require('gulp-strip-comments');
const ngAnotate = require('gulp-ng-annotate');
const uglify = require('gulp-uglify');
const sourcemaps = require('gulp-sourcemaps');
const webserver = require('gulp-webserver');
const karma = require('karma').Server;
gulp.task('clean', function () {
return del([conf.dest], {dot: true});
});
gulp.task("build:dev", function(){
return gulp.src(conf.jsSrc())
.pipe(concat(conf.jsDevFile()))
.pipe(strip())
.pipe(gulp.dest(conf.dest));
});
gulp.task("build:prod", function () {
return gulp.src(conf.jsSrc())
.pipe(sourcemaps.init())
.pipe(concat(conf.jsProdFile()))
.pipe(ngAnotate())
.pipe(uglify())
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest(conf.dest));
});
gulp.task("build", ["build:prod", "build:dev"]);
gulp.task("release", ["test:release"], function () {
gulp.src(conf.dest + "/**/*").pipe(gulp.dest(conf.release));
});
gulp.task("watch", function(){
var watcher = gulp.watch(conf.jsSrc(), ["build"]);
watcher.on("add", logModified);
watcher.on("change", logModified);
watcher.on("delete", logModified);
function logModified(event) {
console.info("File (" + event.path + ") " + event.type + " -> rebuilding");
}
});
gulp.task('serve', function () {
gulp.src(conf.dest)
.pipe(webserver({
port: '20000'
}));
});
gulp.task("start", ["build", "serve", "watch"]);
gulp.task("test", ["build"], function (done) {
new karma({
configFile: conf.test.karmaConf("DEV"),
browsers: ['PhantomJS'],
singleRun: true
}, done).start();
});
gulp.task("test:min", ["build"], function (done) {
new karma({
configFile: conf.test.karmaConf("PROD"),
browsers: ['PhantomJS'],
singleRun: true
}, done).start();
});
gulp.task("test:release", ["build"], function (done) {
new karma({
configFile: conf.test.karmaConf("PROD"),
singleRun: true
}, done).start();
});
gulp.task('tdd', ["build", "watch"], function (done) {
new karma({
configFile: conf.test.karmaConf("DEV"),
browsers: ['PhantomJS']
}, done).start();
});