-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
131 lines (120 loc) · 2.09 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
var browserify = require('browserify');
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var ts = require('gulp-typescript');
var del = require('del');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var watch = require('gulp-watch');
var browserify = require('browserify');
gulp.task(
'clean',
function () {
del('./dest/**/*.html');
del('./dest/**/*.css');
del('./dest/**/*.js');
del('./temp');
return true;
}
);
gulp.task(
'files',
['clean', 'ts'],
function () {
return gulp
.src([
'./src/**/*.html',
'./src/**/*.css',
'./src/**/*.js'
])
.pipe(gulp.dest('./dest/'))
}
);
gulp.task(
'ts',
['clean'],
function () {
var tsResult = gulp.src([
'./src/**/*.ts'
])
.pipe(sourcemaps.init())
.pipe(ts({
sortOutput: true,
module: "commonjs",
noEmitOnError: true,
moduleResolution: 'node'
}));
return tsResult.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('./temp/'));
}
);
gulp.task(
'sounds',
['clean'],
function () {
return gulp
.src([
'./sounds/**/*.wav',
'./sounds/**/*.mp3',
'./sounds/**/*.webm',
])
.pipe(gulp.dest('./dest/sounds'));
}
);
gulp.task(
'images',
['clean'],
function () {
return gulp
.src([
'./images/**/*.png'
])
.pipe(gulp.dest('./dest/images'));
}
);
gulp.task(
'vendor',
['clean'],
function () {
return gulp
.src([
'./vendor/howler.js/dist/howler.core.min.js'
])
.pipe(gulp.dest('./dest/'));
}
);
gulp.task(
'default',
['clean', 'ts', 'files', 'browserify', 'sounds', 'images', 'vendor']
);
gulp.task(
'browserify',
['clean', 'ts'],
function() {
var b = browserify({
entries: './temp/main.js',
debug: true
});
return b.bundle()
.pipe(source('script.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./dest/'));
}
);
gulp.task(
'watch',
function () {
watch([
'src/**/*',
'index.html',
'gulpfile.js'
],
function (events) {
gulp.start('default');
});
}
);