-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.coffee
46 lines (38 loc) · 1.12 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
gulp = require 'gulp'
cjsx = require 'gulp-cjsx'
browserify = require 'browserify'
watchify = require 'watchify'
source = require 'vinyl-source-stream'
lrload = require 'livereactload'
path =
MIN_OUT: 'build.min.js',
OUT: 'build.js',
DEST_SRC: 'static/src',
DEST_BUILD: 'static/build',
DEST: 'static'
ENTRY_POINT: './src/root.cjsx'
buildScript = (files, watch) ->
rebundle = ->
stream = bundler.bundle()
stream
.on 'error', console.log
.pipe source(path.OUT)
.pipe gulp.dest(path.DEST_SRC)
props = watchify.args
props.entries = files
props.debug = true
props.transform = ['coffee-reactify']
props.extensions = ['.cjsx', '.coffee']
bundler = (if watch then watchify(browserify(props)) else browserify(props))
bundler.transform lrload
bundler.on "update", ->
rebundle()
console.log "Rebundled... #{path.ENTRY_POINT}"
rebundle()
gulp.task 'default', ->
buildScript path.ENTRY_POINT, false
gulp.task 'watch', ->
lrloadPath = "#{path.DEST_SRC}/#{path.OUT}"
console.log(lrloadPath)
lrload.monitor lrloadPath, {displayNotification: true}
buildScript path.ENTRY_POINT, true