-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (46 loc) · 1.51 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
var del = require('del');
var run = require('run-sequence');
var gulp = require('gulp');
var ts = require('gulp-typescript');
var tsProject = ts.createProject(require('./tsconfig.json').compilerOptions);
var webpack = require('gulp-webpack');
var mocha = require('gulp-mocha');
gulp.task('clean', function(done) {
del(['.tmp', 'build'], done);
});
gulp.task('copy', function() {
return gulp.src(['app/www/**/*.html', 'app/www/css/**/*.css'], { base: 'app' })
.pipe(gulp.dest('build'));
});
gulp.task('scripts', function() {
var tsResult = gulp.src(['typings/tsd.d.ts', 'app/ts/**/*.ts'], { base: 'app/ts' })
.pipe(ts(tsProject));
return tsResult.js.pipe(gulp.dest('build/js'));
});
gulp.task('prepare-ts', function() {
return gulp.src(['typings/tsd.d.ts', 'app/ts/**/*.ts'], { base: './' })
.pipe(ts(tsProject))
.js.pipe(gulp.dest('.tmp'));
});
gulp.task('prepare-copy', function() {
return gulp.src(['app/www/js/**/*.js'], { base: './' })
.pipe(gulp.dest('.tmp'));
});
gulp.task('webpack', ['prepare-ts', 'prepare-copy'], function() {
return gulp.src(['.tmp/app/www/js/index.js'])
.pipe(webpack({
output: {
filename: 'index.js'
}
}))
.pipe(gulp.dest('build/www/js'));
});
gulp.task('test', ['clean'], function() {
return gulp.src(['app/ts/**/*.ts', 'typings/tsd.d.ts', 'test/**/*.ts'], { base: './' })
.pipe(ts(tsProject))
.js.pipe(gulp.dest('.tmp'))
.pipe(mocha());
});
gulp.task('build', ['clean'], function() {
run('scripts', 'webpack', 'copy');
});