-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
54 lines (47 loc) · 1.3 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
var gulp = require("gulp");
var clean = require('gulp-clean');
var browserify = require("browserify");
var source = require('vinyl-source-stream');
var watchify = require("watchify");
var tsify = require("tsify");
var gutil = require("gulp-util");
var ts = require("gulp-typescript");
var tsProject = ts.createProject("tsconfig.json");
function browserifyBundle() {
return browserify({
basedir: '.',
debug: true,
entries: ['src/dod.ts'],
cache: {},
packageCache: {}
});
} ;
var watchedBrowserify = watchify(browserifyBundle().plugin(tsify));
function compile() {
return tsProject.src()
.pipe(tsProject())
.js.pipe(gulp.dest("dist"));
};
function bundle() {
compile();
return browserifyBundle()
.plugin(tsify)
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest("dist"));
};
function watchBundle() {
compile();
return watchedBrowserify
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest("dist"));
}
gulp.task('clean-scripts', function () {
return gulp.src('dist/**/*.js', {read: false})
.pipe(clean());
});
gulp.task("package", ["clean-scripts"], bundle);
gulp.task("default", ["clean-scripts"], watchBundle);
watchedBrowserify.on("update", bundle);
watchedBrowserify.on("log", gutil.log);