From: Marius Gavrilescu Date: Thu, 2 Apr 2015 08:08:40 +0000 (+0300) Subject: Gzip CSS and JS in make_static.PL X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=3c9bcb475efecdd49e86f09a4cf9da4985031b55;p=gruntmaster-page.git Gzip CSS and JS in make_static.PL --- diff --git a/Makefile.PL b/Makefile.PL index a0b48cb..6da9ecf 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -10,7 +10,7 @@ WriteMakefile( LICENSE => 'AGPL_3', SIGN => 1, clean => { - FILES => 'static/css/ static/js.js static/js.map static/js/' + FILES => 'static/css/ static/js.js static/js.js.gz static/js.map static/js/' }, BUILD_REQUIRES => { qw/CSS::Minifier::XS 0 diff --git a/make_static.PL b/make_static.PL index 0a10891..10532b9 100644 --- a/make_static.PL +++ b/make_static.PL @@ -5,11 +5,17 @@ use warnings; use CSS::Minifier::XS qw//; use JavaScript::Minifier::XS qw//; +use IO::Compress::Gzip qw/gzip/; use File::Slurp qw/read_file write_file/; mkdir 'static'; mkdir 'static/css'; +sub gzip_file { + my ($file) = @_; + gzip $file => "$file.gz", -Level => 9, Minimal => 1; +} + sub make_css { my $common_css; $common_css .= read_file $_ for ; @@ -18,6 +24,7 @@ sub make_css { my $css = read_file $_; $css .= $common_css; write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css; + gzip_file "static/css/$theme.css"; } } @@ -32,6 +39,7 @@ sub make_js { $js .= read_file $_ for ; write_file 'static/js.js', JavaScript::Minifier::XS::minify $js; } + gzip_file 'static/js.js'; } my $css_mtime = -M 'static/css/slate.css' // 0;