-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
113 lines (95 loc) · 2.64 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
"use strict";
var gulp = require('gulp'),
del = require('del'),
uglify = require('gulp-uglify'),
useref = require('gulp-useref'),
gulpif = require('gulp-if'),
minifyCss = require('gulp-clean-css'),
stripDebug = require('gulp-strip-debug'),
runSequence = require('run-sequence'),
ts = require('gulp-typescript'),
Server = require('karma').Server,
e2e = require('gulp-protractor').protractor,
minifyHtml = require("gulp-minify-html");
var source = 'src',
destination = 'dist';
gulp.task('clean', function () {
del([
destination
]);
});
gulp.task("tsc", function () {
var tsProject = ts.createProject('tsconfig.json');
return tsProject.src()
.pipe(tsProject())
.js.pipe(gulp.dest("."));
});
gulp.task('minify', ['tsc'], function () {
gulp.src(source + '/*.html')
.pipe(useref())
.pipe(gulpif('*.js', stripDebug()))
.pipe(gulpif('*.js', uglify()))
.pipe(gulpif('*.css', minifyCss()))
.pipe(gulp.dest('dist'));
});
gulp.task('html', function () {
gulp.src(source + '/app/**/*.html')
.pipe(minifyHtml())
.pipe(gulp.dest(destination + '/app'));
});
gulp.task('fonts', function () {
gulp.src([source + '/lib/bootstrap/fonts/*.*',
source + '/lib/components-font-awesome/fonts/*.*'])
.pipe(gulp.dest(destination + '/fonts'));
});
gulp.task('images', function () {
gulp.src([source + '/img/**/*'])
.pipe(gulp.dest(destination + '/img'));
});
gulp.task('assets', function () {
gulp.src([source + '/assets/**/*'])
.pipe(gulp.dest(destination + '/assets'));
});
gulp.task('watch', ['tsc'], function () {
gulp.watch([source + '/app/**/*.ts'], ['tsc']);
});
gulp.task('default', ['watch']);
gulp.task('compile', ['clean'], function (done) {
runSequence(
['tsc', 'minify', 'fonts', 'html','images','assets'], done);
});
gulp.task('test', ["tsc"], function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('coverage', function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true,
reporters: ['coverage']
}, done).start();
});
gulp.task('tdd', function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
}, done).start();
});
gulp.task('test:chrome', function (done) {
new Server({
configFile: __dirname + 'karma.conf.js',
browsers: ['Chrome']
}, function (exitCode) {
done();
process.exit(exitCode);
}).start();
});
gulp.task('e2e', function (done) {
gulp.src(['test/e2e/**/*.js'])
.pipe(e2e({
configFile: "test/protractor.config.js",
args: ['--baseUrl', 'http://localhost:8000']
}))
.on('end', done);
});