-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (51 loc) · 1.83 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
const gulp = require('gulp'),
mocha = require('gulp-mocha'),
releaseHelper = require('release-helper'),
ts = require('gulp-typescript'),
tsProject = ts.createProject('tsconfig.json'),
fsExtra = require('fs-extra'),
runSequence = require('run-sequence'),
path = require('path'),
webpack = require('webpack'),
exec = require('child_process').exec;
//Init custom release tasks
releaseHelper.init(gulp);
let glue = suffix => gulp.src(`src/**/*.${suffix}`).pipe(gulp.dest('lib'));
let watch = (suffix, tasks) => {
tasks = tasks ? tasks : [suffix];
return gulp.watch(`src/**/*.${suffix}`, tasks);
}
gulp.task('pug', () => glue('pug'));
gulp.task('ts', () => {
let tsResult = tsProject.src()
.pipe(tsProject());
return tsResult.js.pipe(gulp.dest('lib'));
});
gulp.task('watch-ts', () => watch('ts'));
gulp.task('watch-pug', () => watch('pug'));
gulp.task('unit', ['build'], () => {
return gulp.src('test/unit/**/*.js', { read: false })
.pipe(mocha({ require: ['babel-register'] }));
});
gulp.task('it', ['build'], () => {
return gulp.src('test/it/**/*-test.js', { read: false })
.pipe(mocha({ require: ['babel-register'] }));
});
gulp.task('clean', (done) => {
fsExtra.remove('lib', done);
});
gulp.task('default', ['build']);
gulp.task('build-root', done => {
let cfg = require('./src/root/webpack.config');
cfg.output.path = path.resolve('./lib/root/public');
webpack(cfg, done);
});
gulp.task('build-player', done => {
let cfg = require('./src/player/webpack.config');
cfg.output.path = path.resolve('./lib/player/public');
webpack(cfg, done);
});
gulp.task('build-clients', done => runSequence('build-root', 'build-player', done));
gulp.task('build', done => runSequence('clean', ['pug', 'ts', 'build-clients'], done));
gulp.task('dev', ['build', 'watch-pug', 'watch-ts']);
gulp.task('test', ['unit']);