forked from jsbin/jsbin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.php
More file actions
38 lines (29 loc) · 1.11 KB
/
build.php
File metadata and controls
38 lines (29 loc) · 1.11 KB
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
<?php
define('VERSION', trim(file_get_contents('VERSION')));
define('SPROCKETIZED', './js/tmp.' . VERSION . '.js');
define('PRODUCTION', './js/jsbin-' . VERSION . '.js');
// sprocketize the code in to _jsbin.VERSION.js
require_once('lib/sprockets/sprocket.php');
echo "Sprocketizing...\n";
$filePath = './js/jsbin.js';
// prepare sprocket
$sprocket = new Sprocket($filePath, array(
'contentType' => '', // keeps debug quiet
'baseUri' => '../js',
'baseFolder' => array('./js/vendor', './js/vendor/codemirror2'),
'assetFolder' => '..',
'debugMode' => true, // forces to always show
'autoRender' => false
));
// concat complete
echo "Rendering...\n";
$js = $sprocket->render(true);
// write concat to js dir
echo "Writing concatenated file...\n";
file_put_contents(SPROCKETIZED, $js);
// google compile in to jsbin.VERSION.js
echo "Google compiler compressing...\n";
system('java -jar "./lib/compiler.jar" --js="' . SPROCKETIZED . '" --js_output_file="' . PRODUCTION . '" --warning_level=QUIET');
unlink(SPROCKETIZED);
echo "Compressed: " . PRODUCTION . "\nFile size: " . filesize(PRODUCTION) . " bytes.\n";
?>