5 use CSS
::Minifier
::XS qw
//;
6 use JavaScript
::Minifier
::XS qw
//;
8 use Digest
::SHA qw
/sha256_base64/;
9 use IO
::Compress
::Gzip qw
/gzip/;
10 use File
::Slurp qw
/read_file write_file edit_file_lines/;
17 gzip
$file => "$file.gz", -Level
=> 9, Minimal
=> 1;
22 $common_css .= read_file
$_ for <css
/*.css
>;
23 for (<css
/themes/*>) {
24 my ($theme) = m
,themes
/(.*)\
.css
,;
25 my $css = read_file
$_;
27 write_file
"static/css/$theme.css", CSS
::Minifier
::XS
::minify
$css;
28 gzip_file
"static/css/$theme.css";
33 if (-f
'compiler.jar') {
34 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/*>;
35 my $js = read_file
'static/js.js';
36 write_file
'static/js.js', '//# sourceMappingURL=/static/js.map', "\n", $js;
37 system 'cp', '-rp', 'js', 'static/';
40 $js .= read_file
$_ for <js
/*.js
>;
41 write_file
'static/js.js', JavaScript
::Minifier
::XS
::minify
$js;
43 gzip_file
'static/js.js';
46 my $css_mtime = -M
'static/css/slate.css' // 0;
47 for (<css
/*>, <css
/themes
/*>) {
48 if (!$css_mtime || $css_mtime > -M
) {
54 my $js_mtime = -M
'static/js.js' // 0;
56 if (!$js_mtime || $js_mtime > -M
) {
63 my ($file) = m
,(static
.*\
.(?
:css
|js
)),;
65 my $hash = sha256_base64
scalar read_file
$file;
66 s/integrity=".*"/integrity="sha256-$hash="/;