This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.coffee
82 lines (72 loc) · 1.9 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
'use strict'
gulp = require('gulp')
del = require('del')
util = require('gulp-util')
es = require('event-stream')
path = require('path')
browserify = require('browserify')
uglify = require('gulp-uglify')
browserifyGlobalShim = require('browserify-global-shim')
buffer = require('vinyl-buffer')
source = require('vinyl-source-stream')
licensify = require('licensify')
webserver = require('gulp-webserver')
aliasify = require('aliasify')
gzip = require('gulp-gzip')
shell = require('gulp-shell')
destinations =
bundle_js: './example-assets/js'
gulp.task 'js:app', ->
unless util.env.mode in ['release', 'debug']
throw new Error "--mode must be specified. Either " +
"'debug' or 'release' can be specified."
bundle = browserify()
.require([
'patroljs'
'threejs-geometry-hittest'
'three'
'hyper3d'
])
.transform(aliasify,
aliases:
'progress': './src/progressbar-stub'
verbose: true
global: true
)
.plugin(licensify)
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
switch util.env.mode
when 'release'
bundle
.pipe(uglify(
preserveComments: 'license'
))
.pipe(gulp.dest(destinations.bundle_js))
when 'debug'
bundle
.pipe(gulp.dest(destinations.bundle_js))
gulp.task 'js-gzip:app', ['js:app'], ->
gulp.src("#{destinations.bundle_js}/bundle.js")
.pipe(gzip())
.pipe(gulp.dest(destinations.bundle_js))
gulp.task 'build', [
'js-gzip:app'
]
gulp.task 'clean', ->
del [
"#{bundle_js}/bundle.js",
"#{bundle_js}/bundle.js.gz"
], (err, deletedFiles) ->
if deletedFiles.length
util.log 'Deleted', util.colors.red(deletedFiles.join(' ,'))
else
util.log util.colors.yellow('empty - nothing to delete')
return
return
gulp.task 'server', ['build'],
shell.task(["jekyll s"])
gulp.task 'default', [
'build', 'server'
]