mkdir 'static';
mkdir 'static/css';
-my $common_css;
-$common_css .= read_file $_ for <css/*.css>;
-for (<css/themes/*>) {
- 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 <css/*.css>;
+ for (<css/themes/*>) {
+ 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/,, <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 <js/*.js>;
- 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/,, <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 <js/*.js>;
+ write_file 'static/js.js', JavaScript::Minifier::XS::minify $js;
+ }
+}
+
+my $css_mtime = -M 'static/css/slate.css' // 0;
+for (<css/*>, <css/themes/*>) {
+ if (!$css_mtime || $css_mtime > -M) {
+ make_css;
+ last
+ }
+}
+
+my $js_mtime = -M 'static/js.js' // 0;
+for (<js/*>) {
+ if (!$js_mtime || $js_mtime > -M) {
+ make_js;
+ last
+ }
}