From 9cad7bdddc585fce8efed182c91634b2b7e9e354 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sun, 8 Mar 2015 12:15:32 +0200 Subject: [PATCH] Add rudimentary closure compiler support --- Makefile.PL | 2 +- make_static.PL | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 2f3a50f..021ffdb 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -10,7 +10,7 @@ WriteMakefile( LICENSE => 'AGPL_3', SIGN => 1, clean => { - FILES => 'static/css/ static/js.js' + FILES => 'static/css/ static/js.js static/js.map static/js/' }, BUILD_REQUIRES => { qw/CSS::Minifier::XS 0 diff --git a/make_static.PL b/make_static.PL index a47df2d..fe06da9 100644 --- a/make_static.PL +++ b/make_static.PL @@ -19,6 +19,13 @@ for () { write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css; } -my $js; -$js .= read_file $_ for ; -write_file 'static/js.js', JavaScript::Minifier::XS::minify $js; +if (-f 'compiler.jar') { + system java => -jar => 'compiler.jar', qw,-O SIMPLE --create_source_map static/js.map --js_output_file static/js.js --language_in ECMASCRIPT5_STRICT --source_map_location_mapping js/|/static/js/,, ; + my $js = read_file 'static/js.js'; + write_file 'static/js.js', '//# sourceMappingURL=/static/js.map', "\n", $js; + system 'cp', '-rp', 'js', 'static/'; +} else { + my $js; + $js .= read_file $_ for ; + write_file 'static/js.js', JavaScript::Minifier::XS::minify $js; +} -- 2.39.2