forked from JesterXL/gulp-typescript-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
56 lines (48 loc) · 1.19 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
var gulp = require('gulp');
var browserSync = require('browser-sync');
var del = require('del');
var vinylPaths = require('vinyl-paths');
var typescript = require('gulp-typescript');
var concat = require('gulp-concat');
var browserify = require('browserify');
var tsify = require('tsify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
gulp.task('hello', function()
{
console.log('Waaazzuuuuuppp');
});
gulp.task('copyIndex', function()
{
return gulp.src('src/index.html')
.pipe(gulp.dest('./build'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('browserSync', function()
{
browserSync({
server: {
baseDir: './build'
}
});
});
gulp.task('watchFiles', function()
{
gulp.watch('src/index.html', ['copyIndex']);
gulp.watch('src/**/*.ts', ['typescriptIt']);
});
gulp.task('typescriptIt', function()
{
browserify('./src/App.ts')
.plugin(tsify)
.bundle()
.pipe(source('App.js'))
.pipe(buffer())
.pipe(gulp.dest('./build'));
});
gulp.task('clean', function()
{
return gulp.src('./build', {read: false})
.pipe(vinylPaths(del));
});
gulp.task('default', ['clean', 'copyIndex', 'typescriptIt', 'browserSync', 'watchFiles']);