Skip to content
This repository has been archived by the owner on Jun 2, 2018. It is now read-only.

Commit

Permalink
Compress LESS files on external compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreolek committed Jan 17, 2014
1 parent 716e5cf commit aaffc1b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions classes/Less/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function compile($array = '', $media = 'screen')
$config = Kohana::$config->load('less');

// if compression is allowed
if ($config['compress'])
if ($config['compress'] AND $config['vendor_internal'])
{
return HTML::style(self::_combine($stylesheets), array('media' => $media));
}
Expand Down Expand Up @@ -197,7 +197,12 @@ public static function _compile($filename)
exit($ex->getMessage());
}
} else {
$compiled = shell_exec('lessc ' . $filename);
$command ='lessc ';
if (Kohana::$config->load('less')->get('compress'))
{
$command = 'lessc --clean-css ';
}
$compiled = shell_exec($command . $filename);
if (is_null($compiled)) exit($compiled);
$compressed = self::_compress($compiled);
file_put_contents($filename, $compressed);
Expand All @@ -218,7 +223,12 @@ public static function _ccompile($original, $compiled)
return lessc::ccompile($original, $compiled);
} else {
if (!is_file($compiled) || filemtime($original) > filemtime($compiled)) {
return (int) shell_exec('lessc ' . $original . ' >' . $compiled);
$command ='lessc ';
if (Kohana::$config->load('less')->get('compress'))
{
$command = 'lessc --clean-css ';
}
return (int) shell_exec($command . $original . ' >' . $compiled);
} else {
return true;
}
Expand Down

0 comments on commit aaffc1b

Please sign in to comment.