update build scripts to work with UglifyJS2
This commit is contained in:
parent
5f467337f6
commit
9fac165906
@ -1,5 +1,6 @@
|
|||||||
var build = require('./build/build.js'),
|
var build = require('./build/build.js'),
|
||||||
lint = require('./build/hint.js');
|
lint = require('./build/hint.js'),
|
||||||
|
UglifyJS = require('uglify-js');
|
||||||
|
|
||||||
var COPYRIGHT = '/*\n Copyright (c) 2010-2012, CloudMade, Vladimir Agafonkin\n' +
|
var COPYRIGHT = '/*\n Copyright (c) 2010-2012, CloudMade, Vladimir Agafonkin\n' +
|
||||||
' Leaflet is an open-source JavaScript library for mobile-friendly interactive maps.\n' +
|
' Leaflet is an open-source JavaScript library for mobile-friendly interactive maps.\n' +
|
||||||
@ -51,7 +52,7 @@ task('build', ['lint'], function (compsBase32, buildName) {
|
|||||||
|
|
||||||
var path = pathPart + '.js',
|
var path = pathPart + '.js',
|
||||||
oldCompressed = build.load(path),
|
oldCompressed = build.load(path),
|
||||||
newCompressed = COPYRIGHT + build.uglify(content),
|
newCompressed = COPYRIGHT + UglifyJS.minify(files, {warnings: true}).code,
|
||||||
delta = build.getSizeDelta(newCompressed, oldCompressed);
|
delta = build.getSizeDelta(newCompressed, oldCompressed);
|
||||||
|
|
||||||
console.log('\tCompressed size: ' + newCompressed.length + ' bytes (' + delta + ')');
|
console.log('\tCompressed size: ' + newCompressed.length + ' bytes (' + delta + ')');
|
||||||
|
@ -40,14 +40,17 @@ exports.getFiles = function (compsBase32) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.uglify = function (code) {
|
exports.uglify = function (code) {
|
||||||
var pro = uglifyjs.uglify;
|
var toplevel = uglifyjs.parse(code);
|
||||||
|
toplevel.figure_out_scope();
|
||||||
|
|
||||||
var ast = uglifyjs.parser.parse(code);
|
var compressor = uglifyjs.Compressor();
|
||||||
ast = pro.ast_mangle(ast, {mangle: true});
|
var compressed_ast = toplevel.transform(compressor);
|
||||||
ast = pro.ast_squeeze(ast);
|
|
||||||
ast = pro.ast_squeeze_more(ast);
|
|
||||||
|
|
||||||
return pro.gen_code(ast) + ';';
|
compressed_ast.figure_out_scope();
|
||||||
|
compressed_ast.compute_char_frequency();
|
||||||
|
compressed_ast.mangle_names();
|
||||||
|
|
||||||
|
return compressed_ast.print_to_string() + ';';
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.combineFiles = function (files) {
|
exports.combineFiles = function (files) {
|
||||||
|
Loading…
Reference in New Issue
Block a user