public function doProcessFile($file, $replace = false) { $optimizedContent = JSMin::minify(file_get_contents($file)); if ($replace) { return parent::replaceFile($file, $optimizedContent); } else { return $optimizedContent; } }
public function doProcessFile($file, $replace = false) { $optimizedContent = Minify_CSS_Compressor::process(file_get_contents($file)); if ($replace) { return parent::replaceFile($file, $optimizedContent); } else { return $optimizedContent; } }
public function doProcessFile($file, $replace = false) { $cmd = sprintf('java -jar %s/swCombinePlugin/lib/vendor/closure/compiler.jar --js=%s', sfConfig::get('sf_plugins_dir'), $file); $return = false; $output = array(); exec($cmd, $output, $return); if ($return != 0) { throw new RuntimeException('unable to compile the asset with google closure compiler'); } $optimizedContent = implode("\n", $output); if ($replace) { return parent::replaceFile($file, $optimizedContent); } else { return $optimizedContent; } }
public function doProcessFile($file, $replace = false) { if (!function_exists('curl_init')) { throw new RuntimeException('PHP CURL support must be enabled to use the Google Closure Compiler API driver'); } $content = file_get_contents($file); $ch = curl_init(self::SERVICE_URL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'output_info=compiled_code&output_format=text&compilation_level=SIMPLE_OPTIMIZATIONS&js_code=' . urlencode($content)); $optimizedContent = curl_exec($ch); if (200 != ($httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE))) { throw new RuntimeException(sprintf('The Google Closure Compiler API returned an HTTP %d error: %s', $httpCode, $optimizedContent)); } curl_close($ch); if ($replace) { return parent::replaceFile($file, $optimizedContent); } else { return $optimizedContent; } }
public function doProcessFile($file, $replace = false) { $lessCompiler = new lessc(); $optimizedContent = $lessCompiler->parse(file_get_contents($file)); return $replace ? parent::replaceFile($file, $optimizedContent) : $optimizedContent; }