-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
61 lines (51 loc) · 1.41 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
var gulp = require("gulp");
//Browser
var browserify = require("browserify");
var source = require('vinyl-source-stream');
var watchify = require("watchify");
var tsify = require("tsify");
var gutil = require("gulp-util");
//Native
var ts = require("gulp-typescript");
var tsProject = ts.createProject("tsconfig.json");
var paths = {
pages: ['src/static/*']
};
var browserifyTS = browserify({
basedir: '.',
debug: true,
entries: ['src/ts/main.ts'],
cache: {},
packageCache: {}
}).plugin(tsify).ignore('ammo-node').ignore('node-glfw-raub').ignore('node-webgl-raub');
var watchedBrowserify = watchify(browserifyTS);
gulp.task("copy-html", function () {
return gulp.src(paths.pages)
.pipe(gulp.dest("dist"));
});
function bundleWatchify() {
return watchedBrowserify
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest("dist"));
}
gulp.task("default", ["copy-html"], func => {
bundleWatchify();
watchedBrowserify.on("update", bundleWatchify);
watchedBrowserify.on("log", gutil.log);
});
gulp.task("bundle", ["copy-html"], func => {
return browserifyTS
.bundle()
.pipe(stripCode({
start_comment: "start-test-block",
end_comment: "end-test-block"
}))
.pipe(source('bundle.js'))
.pipe(gulp.dest("dist"));
});
gulp.task("native", function () {
return tsProject.src()
.pipe(tsProject())
.js.pipe(gulp.dest("dist_native"));
});