-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjs-compiler.php
40 lines (26 loc) · 1.01 KB
/
js-compiler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require "csx-compiler.php";
require "file-manifest.php";
$csx_manifest_params = File_manifest::read('css/manifest.txt');
$csx_compiler = new CsxCompiler($csx_manifest_params);
$master_js = File_manifest::merge('js/min.manifest.txt', "/************************\n** %PATH%\n************************/\nBenchmark.start('%PATH%');", "Benchmark.stop('%PATH%','load');");
$master_js .= 'Benchmark.stop("all scripts","load");';
$master_js .= '$.extend(window["CSS"],'.$csx_compiler->get_json().');';
file_put_contents('master.js', $master_js);
$optimization_level = 'SIMPLE'; // or ADVANCED
$cmds = array(
// run google's closure compiler on the master js file
'java -jar D:/HTTP/closure/compiler.jar --compilation_level='.$optimization_level.'_OPTIMIZATIONS --language_in=ECMASCRIPT5 --js_output_file=min.master.js --js=master.js > out.txt 2>&1',
);
foreach($cmds as $cmdStr) {
attempt($cmdStr);
}
function attempt($cmd) {
exec($cmd, $out, $err);
echo implode("\n",$out);
if($err) {
echo "\n";
exit(1);
}
}
?>