-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
137 lines (121 loc) · 2.99 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
132
133
134
135
136
137
const concat = require('gulp-concat-util')
const del = require('del')
const gulp = require("gulp");
const gulpif = require('gulp-if')
const insert = require('gulp-insert')
const log = require('fancy-log')
const path = require('path')
const preprocess = require('gulp-preprocess')
const uglify = require('gulp-uglify')
global.distFolder = './dist'
// Clean previous install
function clean (cb) {
return del([path.join(global.distFolder, '/**/*')])
}
// Install Assets
function copyHtml (cb) {
return gulp
.src(['./src/game/index.html'])
.pipe(gulp.dest(global.distFolder))
}
function copyFonts () {
return gulp
.src(['./src/game/assets/fonts/*'])
.pipe(gulp.dest(path.join(global.distFolder, '/fonts')))
}
function copyImages () {
return gulp
.src(['./src/game/assets/images/*'])
.pipe(gulp.dest(path.join(global.distFolder, '/images')))
}
function copySfx () {
return gulp
.src(['./src/game/assets/sfx/*'])
.pipe(gulp.dest(path.join(global.distFolder + '/sfx')))
}
function copyData () {
return gulp
.src(['./data/*'])
.pipe(gulp.dest(path.join(global.distFolder + '/data')))
}
function jsClient () {
const list = [
'./src/common/Base.js',
'./src/common/*.js'
]
return gulp.src(list)
.pipe(preprocess({ context: { TARGET: global.target } }))
.pipe(concat('gibson.min.js', { sep: ';' }))
.pipe(insert.prepend([
'/*! hack the gibson! / http://paulynomial.com */'
].join('\n')))
.pipe(gulpif(global.production, uglify({
mangle: false,
}).on('error', log)))
.pipe(gulp.dest(global.distFolder))
}
function jsVendor () {
return gulp.src([
'./src/deps/async.min.js',
'./src/deps/jquery.min.js',
'./src/deps/stats.min.js',
'./src/deps/tween.min.js',
'./src/deps/underscore.min.js',
'./src/deps/three.min.js',
'./src/deps/threejs/js/controls/*.js',
'./src/deps/threejs/js/geometries/*.js',
'./src/deps/threejs/js/postprocessing/*.js',
'./src/deps/threejs/js/shaders/*.js',
'./src/deps/threejs/js/utils/*.js',
'./src/deps/threejs/js/vr/*.js'
])
.pipe(concat('gibson-deps.min.js', { sep: ';' }))
.pipe(insert.prepend([
'/*! hack the gibson! / http://paulynomial.com */',
'/*! three.js / threejs.org/license */',
'/*! tween.js - http://github.com/sole/tween.js */'
].join('\n')))
.pipe(uglify({
mangle: false
}))
.pipe(gulp.dest(global.distFolder))
}
function webDebug (cb) {
global.production = false
return cb()
}
function webProd (cb) {
global.production = true
return cb()
}
/* Big Boy Build */
const buildDev = gulp.series(
clean,
gulp.parallel(
copyHtml,
copyFonts,
copyImages,
copySfx,
copyData
),
webDebug,
jsClient,
jsVendor,
)
const buildProd = gulp.series(
clean,
gulp.parallel(
copyHtml,
copyFonts,
copyImages,
copySfx,
copyData
),
webProd,
jsClient,
jsVendor,
)
exports.clean = clean
exports.buildDev = buildDev
exports.buildProd = buildProd
exports.default = buildProd