Run the asset through UglifyJs
Overrides FilterInterface::filterDump
Assetic\Filter\FilterInterface::filterDump()
public function filterDump(AssetInterface $asset) {
$pb = $this
->createProcessBuilder($this->nodeBin ? array(
$this->nodeBin,
$this->uglifycssBin,
) : array(
$this->uglifycssBin,
));
if ($this->expandVars) {
$pb
->add('--expand-vars');
}
if ($this->uglyComments) {
$pb
->add('--ugly-comments');
}
if ($this->cuteComments) {
$pb
->add('--cute-comments');
}
// input and output files
$input = tempnam(sys_get_temp_dir(), 'input');
file_put_contents($input, $asset
->getContent());
$pb
->add($input);
$proc = $pb
->getProcess();
$code = $proc
->run();
unlink($input);
if (127 === $code) {
throw new \RuntimeException('Path to node executable could not be resolved.');
}
if (0 !== $code) {
throw FilterException::fromProcess($proc)
->setInput($asset
->getContent());
}
$asset
->setContent($proc
->getOutput());
}