forked from netzpirat/haml-coffee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCakefile
27 lines (20 loc) · 850 Bytes
/
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
browserify = require 'browserify'
fs = require 'fs'
jsp = require('uglify-js').parser
pro = require('uglify-js').uglify
sys = require 'sys'
{spawn} = require 'child_process'
task 'watch', 'Watch src directory and build to lib', ->
coffee = spawn 'coffee', ['--lint', '--output', 'lib', '--watch', 'src']
coffee.stdout.on 'data', (data) -> sys.print data.toString()
coffee.stderr.on 'data', (data) -> sys.print data.toString()
task 'bundle', 'Compile the Haml Coffee compiler client JavaScript bundle', ->
b = browserify()
b.require "#{ __dirname }/lib/haml-coffee"
code = b.bundle()
fs.writeFileSync 'dist/compiler/hamlcoffee.js', code
ast = jsp.parse code
ast = pro.ast_mangle ast
ast = pro.ast_squeeze ast
min = pro.gen_code ast
fs.writeFileSync 'dist/compiler/hamlcoffee.min.js', min