-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
77 lines (64 loc) · 2.05 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
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var elm = require('gulp-elm');
var concat = require('gulp-concat-util');
var audiosprite = require('gulp-audiosprite');
var ghPages = require('gulp-gh-pages');
gulp.task('elm-init', elm.init);
gulp.task('elm-make', ['elm-init'], function(){
return gulp.src('src/main.elm')
.pipe(elm.make({filetype: 'js'}))
.pipe(gulp.dest('build'));
});
gulp.task('lint', function() {
return gulp.src('src/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('sounds:prepare-sprite', function() {
return gulp.src('sounds/*.wav')
.pipe(audiosprite({
log: 'notice',
export: 'mp3,ac3',
format: 'howler',
gap: 0.5,
path: 'sounds/'
}))
.pipe(gulp.dest('build/sounds'));
});
gulp.task('sounds:prepare-js', ['sounds:prepare-sprite'], function() {
return gulp.src('build/sounds/sprite.json')
.pipe(concat('soundSprite.js'))
.pipe(concat.header('var soundSprite = '))
.pipe(concat.footer(';'))
.pipe(gulp.dest('build'));
});
gulp.task('sounds:copy-sounds', ['sounds:prepare-sprite'], function() {
return gulp.src('build/sounds/*.{mp3,ac3}')
.pipe(gulp.dest('build/dist/sounds'));
});
gulp.task('sounds', ['sounds:prepare-js', 'sounds:copy-sounds']);
gulp.task('prepare-js', ['lint', 'elm-make', 'sounds:prepare-js'], function() {
return gulp.src(['build/*.js', 'src/*.js'])
.pipe(concat('asteroids.js'))
.pipe(rename('asteroids.min.js'))
.pipe(uglify())
.pipe(gulp.dest('build/dist/js'));
});
gulp.task('prepare-html', function() {
return gulp.src(['src/*.html'])
.pipe(gulp.dest('build/dist'));
});
gulp.task('build', ['prepare-js', 'prepare-html', 'sounds']);
gulp.task('watch', ['build'], function() {
gulp.watch('src/*.elm', ['build']);
gulp.watch('src/*.js', ['build']);
});
gulp.task('deploy', function() {
gulp.src('build/dist/**/*')
.pipe(ghPages());
});
gulp.task('default', ['build']);