| 1 | package Mojolicious::Plugin::AssetPack::Pipe::Css; | ||||||||||||||||||||||||||||
| 2 | 10 | ▶ | use Mojo::Base 'Mojolicious::Plugin::AssetPack::Pipe'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use Mojolicious::Plugin::AssetPack::Util qw(diag load_module DEBUG); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 15 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 7 | 15 | my ($self, $assets) = @_; | |||||||||||||||||||||||||||
| 8 | 15 | my $store = $self->assetpack->store; | |||||||||||||||||||||||||||
| 9 | 15 | my $file; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 15 | ▶ | return unless $self->assetpack->minify; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 12 | 6 | ▶ | return $assets->each(sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||
| 13 | 6 | my ($asset, $index) = @_; | |||||||||||||||||||||||||||
| 14 | 6 | my $attrs = $asset->TO_JSON; | |||||||||||||||||||||||||||
| 15 | 6 | $attrs->{key} = 'css-min'; | |||||||||||||||||||||||||||
| 16 | 6 | $attrs->{minified} = 1; | |||||||||||||||||||||||||||
| 17 | 6 | ▶ | return if $asset->format ne 'css' or $asset->minified; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$asset->format ne "css" or $asset->minified
MC/DC0%0/2
$asset->format ne "css" or $asset->minified
$asset->format ne "css"
$asset->minified
Truth table33%1/3
A or B
A= $asset->format ne "css"B= $asset->minified
| |||||||||||||||||||||||||||||
| 18 | 6 | ▶ | return $asset->content($file)->minified(1) if $file = $store->load($attrs); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 3 | load_module 'CSS::Minifier::XS'; | |||||||||||||||||||||||||||
| 20 | 3 | diag 'Minify "%s" with checksum %s.', $asset->url, $asset->checksum if DEBUG; | |||||||||||||||||||||||||||
| 21 | 3 | my $css = CSS::Minifier::XS::minify($asset->content); | |||||||||||||||||||||||||||
| 22 | 3 | $asset->content($store->save(\$css, $attrs))->minified(1); | |||||||||||||||||||||||||||
| 23 | 3 | }); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 10 | 1; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =encoding utf8 | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 NAME | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | Mojolicious::Plugin::AssetPack::Pipe::Css - Minify CSS | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | L<Mojolicious::Plugin::AssetPack::Pipe::Css> will minify your "css" assets | ||||||||||||||||||||||||||||
| 37 | if L<Mojolicious::Plugin::AssetPack/minify> is true and the asset is not | ||||||||||||||||||||||||||||
| 38 | already minified. | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | This module requires the optional module L<CSS::Minifier::XS> to minify. | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =head1 METHODS | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =head2 process | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | See L<Mojolicious::Plugin::AssetPack::Pipe/process>. | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | L<Mojolicious::Plugin::AssetPack>. | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||||||||||