mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 03:32:00 +09:00
#19692545 Minifier can use both Google closure compiler and JSMinPlus.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8368 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
4cd47ec681
commit
f73c89d32c
1 changed files with 27 additions and 2 deletions
|
|
@ -57,7 +57,7 @@ function execute($dir) {
|
||||||
|
|
||||||
echo " Minifying JavaScript files...";
|
echo " Minifying JavaScript files...";
|
||||||
$js_files = get_target_files('js', $dir, $files_to_skip);
|
$js_files = get_target_files('js', $dir, $files_to_skip);
|
||||||
|
|
||||||
if(count($js_files) && !class_exists('JSMinPlus')) {
|
if(count($js_files) && !class_exists('JSMinPlus')) {
|
||||||
require dirname(__FILE__).'/minify/jsminplus/jsminplus.php';
|
require dirname(__FILE__).'/minify/jsminplus/jsminplus.php';
|
||||||
}
|
}
|
||||||
|
|
@ -74,7 +74,18 @@ function execute($dir) {
|
||||||
$copyright = '';
|
$copyright = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents($target, $copyright.JSMinPlus::minify($content));
|
if($config['use_closure_compiler']) {
|
||||||
|
$content = closure_compile($content);
|
||||||
|
if(!$content) {
|
||||||
|
echo " CANNOT compile the js file with closure compiler.\n";
|
||||||
|
echo " Trying again with JSMinPlus.\n";
|
||||||
|
$content = JSMinPlus::minify($content);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$content = JSMinPlus::minify($content);
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents($target, $copyright.$content);
|
||||||
|
|
||||||
echo '.';
|
echo '.';
|
||||||
}
|
}
|
||||||
|
|
@ -167,6 +178,20 @@ function get_target_files($ext, $dir, $files_to_skip) {
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closure_compile($content) {
|
||||||
|
require_once dirname(__FILE__).'/../classes/httprequest/XEHttpRequest.class.php';
|
||||||
|
|
||||||
|
$req = new XEHttpRequest('closure-compiler.appspot.com', 80);
|
||||||
|
$ret = $req->send('/compile', 'POST', 5, array(
|
||||||
|
'output_info' => 'compiled_code',
|
||||||
|
'output_format' => 'text',
|
||||||
|
'compilation_level' => 'SIMPLE_OPTIMIZATIONS',
|
||||||
|
'js_code' => $content
|
||||||
|
));
|
||||||
|
|
||||||
|
return $ret->body;
|
||||||
|
}
|
||||||
|
|
||||||
// run main function
|
// run main function
|
||||||
error_reporting(E_ALL & ~E_NOTICE);
|
error_reporting(E_ALL & ~E_NOTICE);
|
||||||
main();
|
main();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue