-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.coffee
47 lines (40 loc) · 1.08 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
gulp = require('gulp')
deku = require 'deku'
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 'html', (cb) ->
require('cirru-script/lib/register')
html = require('./template.cirru')
fs = require('fs')
assets = undefined
content = require './src/content'
app = deku.tree (deku.element content)
env.body = deku.renderString app
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