-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
76 lines (58 loc) · 2.04 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
var gulp = require('gulp');
gulp.task('test-server', function() {
var http = require('http');
var express = require('express');
var app = express();
app.use(express.static('build'));
var server = app.listen(80, function () {
console.log('Test server listening at http://%s:%s', server.address().address, server.address().port);
});
});
gulp.task('download-deps', function (callback) {
var tsd = require('gulp-tsd');
tsd({
command: 'reinstall',
config: './tsd.json'
}, callback);
});
var compileTypescript = function(scriptname, projectdir) {
var ts = require('gulp-typescript');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var tsProject = ts.createProject(projectdir + '/tsconfig.json');
var tsresult = tsProject.src(projectdir + '/**/*.ts')
.pipe(sourcemaps.init())
.pipe(ts(tsProject));
return tsresult.js
.pipe(concat(scriptname))
.pipe(sourcemaps.write())
.pipe(gulp.dest('build'));
}
var compileJavascript = function(scriptname, projectdir) {
concat = require('gulp-concat'),
uglify = require('gulp-uglify');
gulp.src(projectdir + '/**/*.js')
//.pipe(uglify())
.pipe(concat(scriptname))
.pipe(gulp.dest('build'));
}
gulp.task('compilets-script', function () {
compileTypescript("xut.js", 'script');
});
gulp.watch('script/**/*.ts', ['compilets-script']);
gulp.task('compilejs-angular', function () {
compileJavascript("xut-angular.js", 'webapp/angular');
});
gulp.watch('webapp/angular/**/*.js', ['compilejs-angular']);
gulp.task('compilehtml', function() {
var swig = require('gulp-swig');
var htmlmin = require('gulp-htmlmin');
gulp.src('webapp/views/index.html')
.pipe(swig({ defaults: { cache: false}}))
/*.pipe(htmlmin({
collapseWhitespace: true
}))*/
.pipe(gulp.dest('build'))
});
gulp.watch('webapp/views/**/*.html', ['compilehtml']);
gulp.task('default', ['test-server', 'compilets-script', 'compilejs-angular', 'compilehtml']);