]> iEval git - gruntmaster-page.git/blob - make_static.PL
Display format extension instead of format in job list
[gruntmaster-page.git] / make_static.PL
1 #!/usr/bin/perl
2 use v5.14;
3 use warnings;
4
5 use CSS::Minifier::XS qw//;
6 use JavaScript::Minifier::XS qw//;
7
8 use File::Slurp qw/read_file write_file/;
9
10 mkdir 'static';
11 mkdir 'static/css';
12
13 sub make_css {
14 my $common_css;
15 $common_css .= read_file $_ for <css/*.css>;
16 for (<css/themes/*>) {
17 my ($theme) = m,themes/(.*)\.css,;
18 my $css = read_file $_;
19 $css .= $common_css;
20 write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css;
21 }
22 }
23
24 sub make_js {
25 if (-f 'compiler.jar') {
26 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/*>;
27 my $js = read_file 'static/js.js';
28 write_file 'static/js.js', '//# sourceMappingURL=/static/js.map', "\n", $js;
29 system 'cp', '-rp', 'js', 'static/';
30 } else {
31 my $js;
32 $js .= read_file $_ for <js/*.js>;
33 write_file 'static/js.js', JavaScript::Minifier::XS::minify $js;
34 }
35 }
36
37 my $css_mtime = -M 'static/css/slate.css' // 0;
38 for (<css/*>, <css/themes/*>) {
39 if (!$css_mtime || $css_mtime > -M) {
40 make_css;
41 last
42 }
43 }
44
45 my $js_mtime = -M 'static/js.js' // 0;
46 for (<js/*>) {
47 if (!$js_mtime || $js_mtime > -M) {
48 make_js;
49 last
50 }
51 }
This page took 0.053473 seconds and 4 git commands to generate.