5 use CSS
::Minifier
::XS qw
//;
7 use Digest
::SHA qw
/sha256_base64/;
8 use IO
::Compress
::Gzip qw
/gzip/;
9 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 system java
=> -jar
=> 'compiler.jar', qw
,-O SIMPLE
--create_source_map static
/js/js
.map --js_output_file static
/js/all.js
--language_in ECMASCRIPT5_STRICT
--source_map_location_mapping js
/|/static
/js
/,, <js/*>;
34 my $js = read_file
'static/js/all.js';
35 write_file
'static/js/all.js', '//# sourceMappingURL=/static/js/js.map', "\n", $js;
36 system 'cp', '-rp', 'js', 'static/';
37 gzip_file
'static/js/all.js';
40 my $css_mtime = -M
'static/css/slate.css' // 0;
41 for (<css
/*>, <css
/themes
/*>) {
42 if (!$css_mtime || $css_mtime > -M
) {
48 my $js_mtime = -M
'static/js.js' // 0;
50 if (!$js_mtime || $js_mtime > -M
) {
57 my ($file) = m
,(static
.*\
.(?
:css
|js
)),;
59 my $hash = sha256_base64
scalar read_file
$file;
60 s/integrity=".*"/integrity="sha256-$hash="/;