Skip to content

Commit

Permalink
Item2139: Support *::Minifier::XS, if available
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@5104 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelTempest authored and MichaelTempest committed Sep 22, 2009
1 parent 0d63f8f commit 3aaa2f5
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions BuildContrib/lib/Foswiki/Contrib/Build.pm
Expand Up @@ -1073,7 +1073,14 @@ These are selected between depending on which exist on disk.
sub build_js {
my ( $this, $to ) = @_;

unless ( eval { require JavaScript::Minifier } ) {
my $minifier;
if ( eval { require JavaScript::Minifier::XS } ) {
$minifier = \&JavaScript::Minifier::XS::minify;
}
elsif ( eval { require JavaScript::Minifier } ) {
$minifier = \&JavaScript::Minifier::minify;
}
else {
print STDERR "Cannot squish $to: $@\n";
}

Expand All @@ -1085,7 +1092,7 @@ sub build_js {
my $text = <IF>;
close(IF);

$text = JavaScript::Minifier::minify( input => $text );
$text = &{$minifier}( input => $text );

unless ( $this->{-n} ) {
if ( open( IF, '<', $to ) ) {
Expand Down Expand Up @@ -1120,7 +1127,14 @@ Several different name mappings are supported:
sub build_css {
my ( $this, $to ) = @_;

unless ( eval { require CSS::Minifier } ) {
my $minifier;
if ( eval { require CSS::Minifier::XS } ) {
$minifier = \&CSS::Minifier::XS::minify;
}
elsif ( eval { require CSS::Minifier } ) {
$minifier = \&CSS::Minifier::minify;
}
else {
print STDERR "Cannot squish $to: $@\n";
}

Expand All @@ -1132,7 +1146,7 @@ sub build_css {
my $text = <IF>;
close(IF);

$text = CSS::Minifier::minify( input => $text );
$text = &{$minifier}( input => $text );

unless ( $this->{-n} ) {
if ( open( IF, '<', $to ) ) {
Expand Down

0 comments on commit 3aaa2f5

Please sign in to comment.