2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-05-24 14:04:09 +03:00

Merge pull request #13151 from twbs/customizer-uglifyjs2

Customizer: switch to UglifyJS2
This commit is contained in:
XhmikosR
2014-04-21 01:35:17 +03:00
4 changed files with 38 additions and 35 deletions
+25 -3
View File
@@ -276,8 +276,27 @@ window.onload = function () { // wait for load in a dumb way because B-0
return result
}
function generateJavascript(preamble) {
function uglify(js) {
var ast = UglifyJS.parse(js)
ast.figure_out_scope()
var compressor = UglifyJS.Compressor()
var compressedAst = ast.transform(compressor)
compressedAst.figure_out_scope()
compressedAst.compute_char_frequency()
compressedAst.mangle_names()
var stream = UglifyJS.OutputStream()
compressedAst.print(stream)
return stream.toString()
}
function generateJS(preamble) {
var $checked = $('#plugin-section input:checked')
var jqueryCheck = 'if (typeof jQuery === "undefined") { throw new Error("Bootstrap\'s JavaScript requires jQuery") }\n\n'
if (!$checked.length) return false
var js = $checked
@@ -285,9 +304,12 @@ window.onload = function () { // wait for load in a dumb way because B-0
.toArray()
.join('\n')
preamble = cw + preamble
js = jqueryCheck + js
return {
'bootstrap.js': preamble + js,
'bootstrap.min.js': preamble + cw + uglify(js)
'bootstrap.min.js': preamble + uglify(js)
}
}
@@ -351,7 +373,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
' * Config saved to config.json and ' + gistUrl + '\n' +
' */\n'
generateZip(generateCSS(preamble), generateJavascript(preamble), generateFonts(), configJson, function (blob) {
generateZip(generateCSS(preamble), generateJS(preamble), generateFonts(), configJson, function (blob) {
$compileBtn.removeAttr('disabled')
saveAs(blob, 'bootstrap.zip')
})
File diff suppressed because one or more lines are too long
+6 -16
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long