Created
June 5, 2011 12:53
-
-
Save timoxley/1008931 to your computer and use it in GitHub Desktop.
compress 'stitched' code and cache as file
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
package.compile(function (err, source) { | |
var jsp = require("uglify-js").parser; | |
var pro = require("uglify-js").uglify; | |
var ast = jsp.parse(source); // parse code and get the initial AST | |
ast = pro.ast_mangle(ast); // get a new AST with mangled names | |
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations | |
var final_code = pro.gen_code(ast); // compressed code here | |
fs.writeFile(__dirname + '/public/scripts/application.js', final_code, function (err) { | |
if (err) throw err; | |
util.puts('Compiled application.js'); | |
}) | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment