From 8ab4091be491ea123783576129def1fb0a82f1db Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Wed, 16 Nov 2011 13:12:08 +0600 Subject: [PATCH] [cli] added --uglify option --- bin/xjst | 6 ++++++ lib/xjst/compiler.js | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/xjst b/bin/xjst index 4d3fdba..dc4a734 100755 --- a/bin/xjst +++ b/bin/xjst @@ -24,6 +24,12 @@ require('coa').Cmd() .long('no-opt') .flag() .end() + .opt() + .name('uglify') + .title('Minimize js output using uglifyjs') + .short('u').long('uglify') + .flag() + .end() .opt() .name('engine') .title('Optimization engine (sort-group, or fullgen [default])') diff --git a/lib/xjst/compiler.js b/lib/xjst/compiler.js index 04262e0..fde133f 100644 --- a/lib/xjst/compiler.js +++ b/lib/xjst/compiler.js @@ -395,8 +395,12 @@ exports.generate = function generate(templatesAndOther, options) { result = body.join('\n'); } - return uglify.uglify.gen_code(uglify.parser.parse(result), - { beautify: true }); + if (options.uglify) { + return uglify(result); + } else { + return uglify.uglify.gen_code(uglify.parser.parse(result), + { beautify: true }); + } }; exports.compile = function compile(code, filename, options) {