forked from ThatRendle/bamlats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
101 lines (85 loc) · 2.5 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
var gulp = require('gulp'),
bower = require('main-bower-files'),
bowerNormalize = require('gulp-bower-normalize'),
tsc = require('gulp-typescript'),
concat = require('gulp-concat'),
karma = require('karma'),
runSequence = require('run-sequence'),
ngAnnotate = require('gulp-ng-annotate'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
sourcemaps = require('gulp-sourcemaps');
// This compiles the server typescript
gulp.task('server', function () {
var tsResult = gulp.src('serverSrc/*.ts')
.pipe(tsc({
definitionFiles: false,
module: 'commonjs',
target: 'ES5'
}));
return tsResult.js.pipe(gulp.dest('.'));
});
// This copies files from bower_components into the public folder
gulp.task('bower', function () {
return gulp.src(bower(), {base: './bower_components'})
.pipe(bowerNormalize({flatten: true}))
.pipe(gulp.dest('./public/vendor/'));
});
var sources = {
typescript: ["typings/**/*.d.ts", "src/**/*.ts"],
html: ['src/**/*.html'],
css: ['src/css/**/*.css'],
test: ['public/**/*.js', 'test/**/*Spec.js']
};
// Compile the app
gulp.task('typescript', function () {
return gulp.src(sources.typescript)
.pipe(sourcemaps.init())
.pipe(tsc({
noExternalResolve: true,
sortOutput: true,
target: 'ES5'
}))
.pipe(concat('app.js'))
.pipe(gulp.dest('public/js'))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(rename('app.min.js'))
.pipe(gulp.dest('public/js'));
});
// Copy html from the src to the public directory
gulp.task('html', function () {
return gulp.src(sources.html)
.pipe(gulp.dest('public'));
});
// Copy CSS from the src/css to the public/css directory
gulp.task('css', function () {
return gulp.src(sources.css)
.pipe(gulp.dest('public/css'));
});
// Run tests
gulp.task('test', function (done) {
karma.server.start({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, function () {
done();
});
});
gulp.task('default', ['typescript', 'html', 'css']);
// Uses run-sequence to run default build tasks, then test
gulp.task('pre-watch', function (done) {
runSequence(
['bower', 'default'],
'test',
done
);
});
// Start watch
gulp.task('watch', ['pre-watch'], function () {
gulp.watch(sources.typescript, ['typescript']);
gulp.watch(sources.html, ['html']);
gulp.watch(sources.css, ['css']);
gulp.watch(sources.test, ['test']);
});