From: Marius Gavrilescu Date: Mon, 9 Mar 2015 15:09:38 +0000 (+0200) Subject: Do not remake unmodified files X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=cf2b01396b310e9c46c9acb1b835f4e222e2c9bf;p=gruntmaster-page.git Do not remake unmodified files --- diff --git a/make_static.PL b/make_static.PL index fe06da9..0a10891 100644 --- a/make_static.PL +++ b/make_static.PL @@ -10,22 +10,42 @@ use File::Slurp qw/read_file write_file/; mkdir 'static'; mkdir 'static/css'; -my $common_css; -$common_css .= read_file $_ for ; -for () { - my ($theme) = m,themes/(.*)\.css,; - my $css = read_file $_; - $css .= $common_css; - write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css; +sub make_css { + my $common_css; + $common_css .= read_file $_ for ; + for () { + my ($theme) = m,themes/(.*)\.css,; + my $css = read_file $_; + $css .= $common_css; + write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css; + } } -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; +sub make_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; + } +} + +my $css_mtime = -M 'static/css/slate.css' // 0; +for (, ) { + if (!$css_mtime || $css_mtime > -M) { + make_css; + last + } +} + +my $js_mtime = -M 'static/js.js' // 0; +for () { + if (!$js_mtime || $js_mtime > -M) { + make_js; + last + } }