Skip to content

Commit

Permalink
Making it possible to pass options to the JS minification.
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Krämer committed Mar 5, 2015
1 parent b4f9bf7 commit 9150ca4
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion src/Task/Assets/Minify.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ class Minify extends BaseTask
/** @var string $type css|js */
protected $type;

/** @var array $squeezeOptions */
protected $squeezeOptions = [
'singleLine' => true,
'keepImportantComments' => true,
'specialVarRx' => false,
];

/**
* Constructor. Accepts asset file path or string source.
*
Expand Down Expand Up @@ -149,13 +156,48 @@ protected function getMinifiedText()

case 'js':
$jsqueeze = new \JSqueeze();
return $jsqueeze->squeeze($this->text);
return $jsqueeze->squeeze(
$this->text,
$this->squeezeOptions['singleLine'],
$this->squeezeOptions['keepImportantComments'],
$this->squeezeOptions['specialVarRx']
);
break;
}

return false;
}

/**
* Single line option for the JS minimisation.
*
* @return $this;
*/
public function singleLine($singleLine)
{
$this->squeezeOptions['singleLine'] = (bool)$singleLine;
}

/**
* keepImportantComments option for the JS minimisation.
*
* @return $this;
*/
public function keepImportantComments($keepImportantComments)
{
$this->squeezeOptions['keepImportantComments'] = (bool)$keepImportantComments;
}

/**
* specialVarRx option for the JS minimisation.
*
* @return $this;
*/
public function specialVarRx($specialVarRx)
{
$this->squeezeOptions['specialVarRx'] = (bool)$specialVarRx;
}

/**
* @return string
*/
Expand Down

0 comments on commit 9150ca4

Please sign in to comment.