-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
107 lines (101 loc) · 2.32 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
var gulp = require('gulp'),
rjs = require('gulp-requirejs'),
rename = require('gulp-rename'),
bower = require('gulp-bower'),
gulpFilter = require('gulp-filter'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
mainBowerFiles = require('main-bower-files'),
del = require('del'),
vinylPaths = require('vinyl-paths'),
bowerpkg = require(__dirname+'/bower.json');
gulp.task('bower', function(){
var mainFilter = gulpFilter(['*','!**/main.js']);
switch(process.env.NODE_ENV) {
case "production":
case "development":
default:
gulp.src(mainBowerFiles())
.pipe(rename(function(path){
for(var i in bowerpkg.dependencies)
if(~path.basename.indexOf(i.replace(/js$/,'')))
path.basename = i.replace(/js$/,'');
}))
.pipe(gulp.dest('public/lib'));
gulp.src("style.css")
.pipe(gulp.dest('public'));
}
});
gulp.task('controller', function(){
switch(process.env.NODE_ENV) {
case "production":
case "development":
default:
gulp.src(['src/*.js','!**/main.js'])
.pipe(gulp.dest('public/src'));
gulp.src(['src/main.js'])
.pipe(gulp.dest('public'));
}
});
gulp.task('images', function(){
switch(process.env.NODE_ENV) {
case "production":
case "development":
default:
gulp.src(['images/*'])
.pipe(imagemin({
optimizationLevel: 5,
progressive: true,
interlaced: true
}))
.pipe(gulp.dest('public/images'));
}
})
gulp.task('requirejsBuild', function(){
rjs({
baseUrl: './public',
out : 'main.js',
name: 'main',
fileExclusionRegExp: /socket\.io\/socket\.io\.js/,
paths: {
bomberMan : "src/bomber_man",
enemy : "src/enemy",
imageHandler : "src/image_handler",
game : "src/game",
easeljs : "lib/easel",
underscore : "lib/underscore",
interproc : "src/intervalProcess",
socketio : "empty:"
},
shim: {
game : {
deps : [
'enemy',
'bomberMan',
'imageHandler',
'underscore'
]
},
imageHandler : {
deps : [
'easeljs',
'underscore'
]
},
easeljs : {
exports : 'createjs'
},
socketio : {
exports : 'io'
},
underscore : {
exports : '_'
}
}
})
.pipe(uglify())
.pipe(gulp.dest('public'));
gulp.src(['public/src'])
.pipe(vinylPaths(del));
})
gulp.task('default', ['bower', 'controller', 'images']);