5 use CSS
::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 my $maker = Local
::CSS
::SpriteMaker
->new(
18 css_class_prefix
=> 'logo-',
19 rc_override_classname
=> sub {
21 $name =~ s/-light/.logo-light/r;
26 source_images
=> ['logos/'],
27 target_file
=> 'static/logos.png',
28 add_extra_padding
=> 10,
32 filename
=> 'css/logos.css',
33 sprite_filename
=> '/static/logos.png',
36 system 'pngnq-s9', '-s1', 'static/logos.png';
37 system 'optipng', '-o7', '-zm1-9', 'static/logos-nq8.png';
38 rename 'static/logos-nq8.png', 'static/logos.png';
43 gzip
$file => "$file.gz", -Level
=> 9, Minimal
=> 1;
48 $common_css .= read_file
$_ for <css
/*.css
>;
49 for (<css
/themes/*>) {
50 my ($theme) = m
,themes
/(.*)\
.css
,;
51 my $css = read_file
$_;
53 write_file
"static/css/$theme.css", CSS
::Minifier
::XS
::minify
$css;
54 gzip_file
"static/css/$theme.css";
59 system java
=> -jar
=> 'compiler.jar', qw
,-O SIMPLE
--create_source_map static
/js/js
.map --js_output_file static
/js/all.js
--language_in ECMASCRIPT6_STRICT
--language_out ECMASCRIPT5_STRICT
--source_map_location_mapping js
/|/static
/js
/,, <js/*>;
60 my $js = read_file
'static/js/all.js';
61 write_file
'static/js/all.js', '//# sourceMappingURL=/static/js/js.map', "\n", $js;
62 system 'cp', '-rp', 'js', 'static/';
63 gzip_file
'static/js/all.js';
66 my $sprite_mtime = -M
'static/logos.png' // 0;
68 if (!$sprite_mtime || $sprite_mtime > -M
) {
74 my $css_mtime = -M
'static/css/slate.css' // 0;
75 for (<css
/*>, <css
/themes
/*>) {
76 if (!$css_mtime || $css_mtime > -M
) {
82 my $js_mtime = -M
'static/js.js' // 0;
84 if (!$js_mtime || $js_mtime > -M
) {
91 my ($file) = m
,(static
.*\
.(?
:css
|js
)),;
93 my $hash = sha256_base64
scalar read_file
$file;
94 s/integrity=".*"/integrity="sha256-$hash="/;
98 Local
::CSS
::SpriteMaker
;
100 use parent qw
/CSS::SpriteMaker/;
102 sub _get_stylesheet_string
{
104 my @ret = split "\n", $self->SUPER::_get_stylesheet_string
(@_);
109 background-image: url("/static/logos.png");
110 background-repeat: no-repeat;
111 display: inline-block;
112 vertical-align: middle;