-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
54 lines (46 loc) · 1.44 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 browserSync = require('browser-sync').create();
var exec = require('child_process').exec;
var paths = {
pages: ['src/*.html'],
media: ['src/media/*', './node_modules/phaser/docs/img/phaser.png'],
appRoot: ['src/main.ts'],
phaser: ['./node_modules/phaser/build/phaser.js'],
requirejs: ['./node_modules/requirejs/require.js'],
dist: './dist'
};
gulp.task('default', ['browser-sync']);
gulp.task('copy-html', function () {
return gulp.src(paths.pages)
.pipe(gulp.dest(paths.dist));
});
gulp.task('copy-phaser', function() {
return gulp.src(paths.phaser)
.pipe(gulp.dest(paths.dist));
});
gulp.task('copy-requirejs', function() {
return gulp.src(paths.requirejs)
.pipe(gulp.dest(paths.dist));
});
gulp.task('copy-media', function() {
return gulp.src(paths.media)
.pipe(gulp.dest(paths.dist + '/media'));
});
gulp.task('ts', function (cb) {
exec('tsc', function (err, stdout, stderr) {
console.log('Typescript:\n',stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('browser-sync', ['ts', 'copy-phaser', 'copy-media', 'copy-requirejs', 'copy-html'], function() {
browserSync.init({
server: {
baseDir: './',
fallback: 'index.html'
}
});
gulp.watch('src/*.ts', ['ts']).on('change', browserSync.reload);
gulp.watch('src/*.html', ['copy-html']);
gulp.watch('src/', ['copy-media']);
});