-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
66 lines (54 loc) · 1.7 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
var gulp = require('gulp');
var typescript = require('gulp-typescript');
var concat = require('gulp-concat');
var del = require('del');
var merge = require('merge2');
var less = require('gulp-less');
var paths = {
html: ['game/src/**/*.html'],
styles: ['game/src/**/*.less'],
scripts: ['game/src/**/*.ts'],
vendor: ['game/vendor/**/*.*']
};
//------------------------------------------------------------------------------
gulp.task('clean', function(cb) {
del(['build'], cb);
});
//------------------------------------------------------------------------------
gulp.task('vendor', ['clean'], function() {
return gulp.src(paths.vendor).pipe(gulp.dest('build/vendor'));
});
gulp.task('html', ['clean'], function () {
return gulp.src(paths.html).pipe(gulp.dest('build'));
});
gulp.task('styles', ['clean'], function () {
return gulp.src(paths.styles)
.pipe(less())
.pipe(gulp.dest('build/styles'));
});
gulp.task('scripts', ['clean'], function() {
var vendorResult = gulp.src(paths.vendor)
.pipe(gulp.dest('build/vendor'));
var tsResult = gulp.src(paths.scripts)
.pipe(typescript({
declarationFiles: true,
noExternalResolve: false,
module: 'amd',
target: 'es5'
}));
return merge([
vendorResult,
tsResult.dts.pipe(gulp.dest('build/definitions')),
tsResult.js.pipe(gulp.dest('build/js'))
]);
});
// Rerun the task when a file changes
gulp.task('watch', function() {
gulp.watch(paths.scripts, ['build']);
gulp.watch(paths.html, ['build']);
gulp.watch(paths.vendor, ['build']);
gulp.watch(paths.styles, ['build']);
});
// The default task (called when you run `gulp` from cli)
gulp.task('build', ['clean', 'scripts', 'styles', 'vendor', 'html', 'watch']);
gulp.task('default', ['build']);