Created
December 30, 2010 22:59
-
-
Save michaelficarra/760455 to your computer and use it in GitHub Desktop.
only minify browser build if you have uglifyjs installed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task 'build:browser', 'rebuild the merged script for inclusion in the browser', -> | |
code = '' | |
for name in ['helpers', 'rewriter', 'lexer', 'parser', 'scope', 'nodes', 'coffee-script', 'browser'] | |
code += """ | |
require['./#{name}'] = new function() { | |
var exports = this; | |
#{fs.readFileSync "lib/#{name}.js"} | |
}; | |
""" | |
code = """ | |
this.CoffeeScript = function() { | |
function require(path){ return require[path]; } | |
#{code} | |
return require['./coffee-script'] | |
}() | |
""" | |
try | |
{parser, uglify} = require 'uglify-js' | |
ast = parser.parse code | |
code = uglify.gen_code uglify.ast_squeeze uglify.ast_mangle ast, extra: yes | |
fs.writeFileSync 'extras/coffee-script.js', header + '\n' + code | |
invoke 'test:browser' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Cakefile b/Cakefile | |
index e656699..231c6e3 100644 | |
--- a/Cakefile | |
+++ b/Cakefile | |
@@ -94,15 +94,17 @@ task 'build:browser', 'rebuild the merged script for inclusion in the browser', | |
#{fs.readFileSync "lib/#{name}.js"} | |
}; | |
""" | |
- {parser, uglify} = require 'uglify-js' | |
- ast = parser.parse """ | |
+ code = """ | |
this.CoffeeScript = function() { | |
function require(path){ return require[path]; } | |
#{code} | |
return require['./coffee-script'] | |
}() | |
""" | |
- code = uglify.gen_code uglify.ast_squeeze uglify.ast_mangle ast, extra: yes | |
+ try | |
+ {parser, uglify} = require 'uglify-js' | |
+ ast = parser.parse code | |
+ code = uglify.gen_code uglify.ast_squeeze uglify.ast_mangle ast, extra: yes | |
fs.writeFileSync 'extras/coffee-script.js', header + '\n' + code | |
invoke 'test:browser' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment