-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
62 lines (46 loc) · 1.54 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
var gulp = require("gulp");
var gutil = require('gulp-util');
var typescript = require("gulp-typescript");
var sourcemaps = require('gulp-sourcemaps');
var merge = require('merge2');
var browserify = require('browserify');
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var gutil = require('gulp-util');
var tsify = require('tsify');
const aiProject = typescript.createProject("./tsconfig.ai.json", {declaration: true});
const workerProject = require("./tsconfig.worker.json");
gulp.task('lift', ["compile"], function()
{
gulp.watch("source/**/*.ts", ["compile"]);
});
gulp.task('compile', ["ai-compile", "worker-compile"]);
// Compile full bundle Chess + Chessboard
gulp.task("ai-compile", function ()
{
var tsResults = gulp.src("source/ChessAI/**/*.ts")
.pipe(sourcemaps.init())
.pipe(aiProject());
return merge([
tsResults.dts.pipe(gulp.dest('./build/ChessAI/')),
tsResults.js.pipe(sourcemaps.write('./')).pipe(gulp.dest('./build/ChessAI/'))
]);
});
// Compile full bundle Chess + Chessboard
gulp.task("worker-compile", function ()
{
var bundler = browserify({
debug: true,
})
.add('source/AIWorker/worker.ts')
.plugin(tsify, workerProject.compilerOptions);
return bundler.bundle()
.on('error', function (error) { console.error(error.toString()); })
.pipe(source('worker.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest("./build/worker/"));
});