-
Notifications
You must be signed in to change notification settings - Fork 244
/
gulpfile.js
48 lines (42 loc) · 1.53 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
var gulp = require('gulp');
var connect = require('gulp-connect');
var audiosprite = require('./vendor/audiosprite');
var glob = require('glob');
var shell = require('gulp-shell');
var fs = require('fs');
gulp.task('audio', gulp.parallel(function(cb) {
var files = glob.sync('./src/assets/sounds/*.mp3');
var outputPath = './dist/audio';
var opts = {
output: outputPath,
path: './',
format: 'howler2',
'export': 'ogg,mp3',
loop: ['quacking', 'sniff']
};
return audiosprite(files, opts, function(err, obj) {
if (err) {
console.error(err);
}
return fs.writeFile('./dist/audio' + '.json', JSON.stringify(obj, null, 2), cb);
});
}));
gulp.task('images', gulp.parallel(function(){
// There is a texturepacker template for spritesmith but it doesn't work
// well with complex directory structures, so instead we use the shell
// checking TexturePacker --version first ensures it bails if TexturePacker
// isn't installed
return gulp.src('*', {read:false})
.pipe(shell([
'TexturePacker --version || echo ERROR: TexturePacker not found, install TexturePacker',
'TexturePacker --disable-rotation --data dist/sprites.json --format json --sheet dist/sprites.png src/assets/images'
]))
.pipe(connect.reload());
}));
gulp.task('deploy', gulp.parallel(function() {
return gulp.src('*', {read:false})
.pipe(shell([
'aws --profile duckhunt s3 sync dist/ s3://duckhuntjs.com --include \'*\' --acl \'public-read\''
]));
}));
gulp.task('default', gulp.parallel('images', 'audio'));