gulpfile.js
1.42 KB
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
const gulp = require('gulp');
const browserify = require('browserify');
const watchify = require('watchify');
const errorify = require('errorify');
const del = require('del');
const tsify = require('tsify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const runSequence = require('run-sequence');
const uglify = require('gulp-uglify');
gulp.task('clean', () => {
return del('./built/**/*')
});
gulp.task('prod', () => {
browserify({
basedir: '.',
debug: true,
entries: ['src'],
cache: {},
packageCache: {}
})
.plugin(tsify)
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('built'));
});
gulp.task('dev', () => {
browserify({
basedir: '.',
debug: true,
entries: ['src'],
cache: {},
packageCache: {}
})
.plugin(tsify)
.plugin(watchify)
.plugin(errorify)
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('built'));
});
gulp.task('default', (done) => {
runSequence('clean', 'dev', () => {
console.log('Watching...')
gulp.watch(['src/**/*.ts'],
['dev']);
});
});
gulp.task('package', (done) => {
runSequence('clean', 'prod', () => {
console.log('Watching...')
gulp.watch(['src/**/*.ts'],
['prod']);
});
});