-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.coffee
60 lines (52 loc) · 1.33 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
'use strict'
gulp = require('gulp')
sequence = require('run-sequence')
exec = require('child_process').exec
env =
dev: true
main: 'http://localhost:8080/build/main.js'
gulp.task 'script', ->
coffee = require('gulp-coffee')
gulp
.src 'src/*.coffee'
.pipe coffee()
.pipe gulp.dest('lib/')
gulp.task 'rsync', (cb) ->
wrapper = require 'rsyncwrapper'
wrapper.rsync
ssh: true
src: ['index.html', 'build']
recursive: true
args: ['--verbose']
dest: 'talk-ui:/teambition/server/talk-ui/react-lite-layered'
deleteAll: true
, (error, stdout, stderr, cmd) ->
if error?
throw error
console.error stderr
console.log cmd
cb()
gulp.task 'html', (cb) ->
require('cirru-script/lib/register')
html = require('./template.cirru')
fs = require('fs')
assets = undefined
unless env.dev
assets = require('./build/assets.json')
env.main = './build/' + assets.main
fs.writeFile 'index.html', html(env), cb
gulp.task 'del', (cb) ->
del = require('del')
del [ 'build' ], cb
gulp.task 'webpack', (cb) ->
if env.dev
command = 'webpack'
else
command = 'webpack --config webpack.min.coffee --progress'
exec command, (err, stdout, stderr) ->
console.log stdout
console.log stderr
cb err
gulp.task 'build', (cb) ->
env.dev = false
sequence 'del', 'webpack', 'html', cb