This repository has been archived by the owner on Jul 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gulpfile.coffee
75 lines (58 loc) · 2.02 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
gulp = require("gulp")
util = require("gulp-util")
wrap = require("gulp-wrap")
template = require("gulp-template")
concat = require("gulp-concat")
coffee = require("gulp-coffee")
uglify = require("gulp-uglify")
series = require("stream-series")
notifier = require("node-notifier")
# Set NODE_ENV=development for non-unglified JS.
env = process.env.NODE_ENV or "production"
path =
public: "public/"
models: "public/models/"
collections: "public/collections/"
views: "public/views/"
vendor: "public/vendor/"
wrapper: "public/wrapper/"
gulp.task "build", ->
zepto = gulp.src(path.vendor + "zepto-*.js")
underscore = gulp.src(path.vendor + "underscore-*.js")
backbone = gulp.src(path.vendor + "backbone-*.js")
picoModal = gulp.src(path.vendor + "pico_modal-*.js")
vendor = series(zepto, underscore, backbone, picoModal)
.pipe(concat("site.js"))
.pipe(wrap(src: path.wrapper + "vendor.js"))
.on("error", util.log)
app =
gulp.src(path.public + "app.coffee")
.pipe(template(env: env))
.pipe(coffee(bare: true))
models =
gulp.src(path.models + "*.coffee")
.pipe(coffee(bare: true))
collections =
gulp.src(path.collections + "*.coffee")
.pipe(coffee(bare: true))
views =
gulp.src(path.views + "*.coffee")
.pipe(coffee(bare: true))
init =
gulp.src(path.public + "init.coffee")
.pipe(coffee(bare: true))
result = series(vendor, app, models, collections, views, init)
.pipe(concat("site.js"))
.pipe(wrap(src: path.wrapper + "app.js"))
if env is "production"
result = result.pipe(uglify())
result.pipe(gulp.dest(path.public))
gulp.task "watch", ["build"], ->
gulp.watch path.wrapper + "*.js", ["build"]
gulp.watch path.vendor + "*.js", ["build"]
gulp.watch path.public + "**/*.coffee", ["build"]
process.on "uncaughtException", (error) ->
console.error(error)
if typeof error is "object"
notifier.notify
message: "Error [#{error.plugin}] #{error.message}"