-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
50 lines (42 loc) · 1.13 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
const gulp = require("gulp");
const browserify = require("browserify");
const source = require('vinyl-source-stream');
const tsify = require("tsify");
const watchify = require("watchify");
const gutil = require("gulp-util");
const terser = require("gulp-terser");
const buffer = require('vinyl-buffer');
const mocha = require('gulp-mocha');
const destination = './dist';
function onError(error) {
return gutil.log(gutil.colors.red(error.message));
}
function build(debug) {
return browserify('src/main.ts', {
standalone: 'bundle',
debug: debug
})
.plugin(tsify);
}
const watchedBrowserify = watchify(build(true));
function bundle() {
return watchedBrowserify
.bundle()
.on('error', onError)
.pipe(source('main.js'))
.pipe(buffer())
.pipe(terser())
.pipe(gulp.dest(destination));
}
gulp.task("default", gulp.series(bundle));
watchedBrowserify.on("update", bundle);
watchedBrowserify.on("log", gutil.log);
gulp.task('dev', function() {
return bundle();
});
gulp.task('run-tests', function() {
return gulp.src('test/*.spec.ts')
.pipe(mocha({
require: ['ts-node/register']
}));
});