forked from gbtami/pychess-variants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
52 lines (44 loc) · 1.2 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
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 buffer = require('vinyl-buffer');
const destination = './static';
function onError(error) {
return gutil.log(gutil.colors.red(error.message));
};
function build(debug) {
return browserify('client/main.ts', {
standalone: 'PychessVariants',
debug: debug
})
.plugin(tsify);
}
const watchedBrowserify = watchify(build(true));
function bundle() {
return watchedBrowserify
.bundle()
.on('error', onError)
.pipe(source('pychess-variants.js'))
.pipe(buffer())
.pipe(gulp.dest(destination));
}
gulp.task("default", bundle);
watchedBrowserify.on("update", bundle);
watchedBrowserify.on("log", gutil.log);
gulp.task('dev', function() {
return build(true)
.bundle()
.on('error', onError)
.pipe(source('pychess-variants.js'))
.pipe(gulp.dest(destination));
});
gulp.task('prod', function() {
return build(false)
.bundle()
.on('error', onError)
.pipe(source('pychess-variants.min.js'))
.pipe(gulp.dest(destination));
});