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