Skip to content

Commit

Permalink
[cli] added --uglify option
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Nov 16, 2011
1 parent 196f50a commit 8ab4091
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions bin/xjst
Expand Up @@ -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])')
Expand Down
8 changes: 6 additions & 2 deletions lib/xjst/compiler.js
Expand Up @@ -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) {
Expand Down

0 comments on commit 8ab4091

Please sign in to comment.