forked from dodo/node-formatdate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCakefile
41 lines (38 loc) · 1.3 KB
/
Cakefile
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
path = require 'path'
{ run, compileScript, minifyScript, writeFile, notify } = require 'muffin'
task 'compile', 'compile coffeescript → javascript', (options) ->
run
options:options
after:options.after
files:[
"./src/**/*.coffee"
]
map:
'src/(.+).coffee': (m) ->
compileScript m[0], path.join("lib" ,"#{m[1]}.js"), options
task 'bundle', 'build a browser bundle', (options) ->
browserify = require 'browserify'
{ createScope } = require 'scopify'
run
options:options
files:[
"./lib/*.js"
]
map:
'lib/(formatdate).js': (m) ->
bundle = browserify({
require: path.join(__dirname, m[0])
cache: on
}).use(createScope require:'./'+m[1]).bundle()
notify m[0], "successful browserify!"
filename = "#{m[1]}.browser.js"
writeFile(filename, bundle, options).then ->
minifyScript filename, options
task 'build', 'compile && bundle', (options) ->
timeout = 0
options.after = ->
clearTimeout(timeout) if timeout
timeout = setTimeout( ->
invoke 'bundle', options
, 250)
invoke 'compile'