-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.coffee
95 lines (85 loc) · 2.52 KB
/
gulpfile.coffee
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
### The following gulpfile compiles coffeescript and places it in the build folder along with minified game assets. ###
### Gulp and processing plugins. ###
gulp = require('gulp')
gutil = require('gulp-util')
coffee = require('gulp-coffee')
concat = require('gulp-concat')
sass = require('gulp-sass')
changed = require('gulp-changed')
imagemin = require('gulp-imagemin')
minifyHTML = require('gulp-minify-html')
### Source and build destination directories for files. ###
# The conatenation order of javascript files is important. Otherwise there will be errors
coffeeSrc = [
'./src/script/EffectsManager.coffee',
'./src/script/*State.coffee',
'./src/script/main.coffee',
'./src/script/GameWorld.coffee',
'./src/script/Powerup.coffee',
'./src/script/*.coffee'
]
coffeeDst = './build/script'
libSrc = './src/lib/*.js'
libDst = './build/lib'
imgSrc = './src/img/*'
imgDst = './build/img'
fontsSrc = './src/fonts/*'
fontsDst = './build/fonts'
audioSrc = './src/audio/*'
audioDst = './build/audio'
htmlSrc = './src/*.html'
htmlDst = './build/'
styleSrc = './src/styles/*.scss'
styleDst = './build/css'
# Build CoffeeScript files
gulp.task 'coffee', ->
gulp.src(coffeeSrc).pipe(concat('main.coffee')).pipe(coffee(bare: true).on('error', gutil.log)).pipe gulp.dest(coffeeDst)
return
# Copy JavaScript libraries
gulp.task 'lib', ->
gulp.src(libSrc).pipe gulp.dest(libDst)
return
# Copy image files
gulp.task 'img', ->
gulp.src(imgSrc).pipe gulp.dest(imgDst)
return
# Copy fonts
gulp.task 'fonts', ->
gulp.src(fontsSrc).pipe gulp.dest(fontsDst)
return
# Copy audio
gulp.task 'audio', ->
gulp.src(audioSrc).pipe gulp.dest(audioDst)
return
# Copy html files
gulp.task 'html', ->
gulp.src(htmlSrc).pipe(minifyHTML()).pipe gulp.dest(htmlDst)
gulp.src('./src/favicon/*').pipe gulp.dest('./build')
return
# Build stylesheet files
gulp.task 'style', ->
gulp.src(styleSrc).pipe(sass()).pipe gulp.dest(styleDst)
return
# Default task (this is run when you type 'gulp' in the root directory)
gulp.task 'default', [
'coffee'
'lib'
'img'
'audio'
'html'
'style'
'fonts'
], ->
# watch for changes in CoffeeScript files
gulp.watch coffeeSrc, [ 'coffee' ]
# watch for changes in image files
gulp.watch imgSrc, [ 'img' ]
# watch for changes in html files
gulp.watch htmlSrc, [ 'html' ]
# watch for changes in stylesheets
gulp.watch styleSrc, [ 'style' ]
# watch for changes in fonts
gulp.watch styleSrc, [ 'fonts' ]
# watch for changes in audio
gulp.watch styleSrc, [ 'audio' ]
return