From 1bb102efb1444ab35e5cd8d2493d5e15ab00bc3f Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Wed, 10 Dec 2014 16:16:19 +0200 Subject: [PATCH] Do not minify CSS/JS in development --- lib/Plack/App/Gruntmaster.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Plack/App/Gruntmaster.pm b/lib/Plack/App/Gruntmaster.pm index c8b04f3..3cb3809 100644 --- a/lib/Plack/App/Gruntmaster.pm +++ b/lib/Plack/App/Gruntmaster.pm @@ -52,6 +52,8 @@ use constant FORMAT_EXTENSION => { use constant NOT_FOUND => [404, ['Content-Type' => 'text/plain'], ['Not found']]; use constant FORBIDDEN => [401, ['Content-Type' => 'text/plain', 'WWW-Authenticate' => 'Basic realm="Gruntmaster 6000"'], ['Forbidden']]; +sub development() { ($ENV{PLACK_ENV} // 'development') eq 'development' } + my $env; sub db { $env->{'gruntmaster.dbic'} } @@ -94,14 +96,14 @@ sub dispatch_request{ my $css = read_file "css/themes/$theme.css"; $css .= read_file $_ for ; my @headers = ('X-Forever' => 1, 'Cache-Control' => 'public, max-age=604800', 'Content-Type' => 'text/css'); - [200, \@headers, [CSS::Minifier::XS::minify $css]] + [200, \@headers, [development ? $css : CSS::Minifier::XS::minify $css]] }, sub (/js.js) { my $js; $js .= read_file $_ for ; my @headers = ('X-Forever' => 1, 'Cache-Control' => 'public, max-age=604800', 'Content-Type' => 'application/javascript'); - [200, \@headers, [JavaScript::Minifier::XS::minify $js]] + [200, \@headers, [development ? $js : JavaScript::Minifier::XS::minify $js]] }, sub (/src/:job) { -- 2.39.2