2 namespace Robo\Task\Assets;
12 * 'scss/default.scss' => 'css/default.css'
14 * ->importDir('assets/styles')
19 * Use the following scss compiler in your project:
22 * "leafo/scssphp": "~0.1",
25 * You can implement additional compilers by extending this task and adding a
26 * method named after them and overloading the scssCompilers() method to
27 * inject the name there.
29 class Scss extends CssPreprocessor
31 const FORMAT_NAME = 'scss';
36 protected $compilers = [
37 'scssphp', // https://github.com/leafo/scssphp
42 * @link https://github.com/leafo/scssphp
48 protected function scssphp($file)
50 if (!class_exists('\Leafo\ScssPhp\Compiler')) {
51 return Result::errorMissingPackage($this, 'scssphp', 'leafo/scssphp');
54 $scssCode = file_get_contents($file);
55 $scss = new \Leafo\ScssPhp\Compiler();
57 // set options for the scssphp compiler
58 if (isset($this->compilerOptions['importDirs'])) {
59 $scss->setImportPaths($this->compilerOptions['importDirs']);
62 if (isset($this->compilerOptions['formatter'])) {
63 $scss->setFormatter($this->compilerOptions['formatter']);
66 return $scss->compile($scssCode);
70 * Sets the formatter for scssphp
72 * The method setFormatter($formatterName) sets the current formatter to $formatterName,
73 * the name of a class as a string that implements the formatting interface. See the source
74 * for Leafo\ScssPhp\Formatter\Expanded for an example.
76 * Five formatters are included with leafo/scssphp:
77 * - Leafo\ScssPhp\Formatter\Expanded
78 * - Leafo\ScssPhp\Formatter\Nested (default)
79 * - Leafo\ScssPhp\Formatter\Compressed
80 * - Leafo\ScssPhp\Formatter\Compact
81 * - Leafo\ScssPhp\Formatter\Crunched
83 * @link http://leafo.github.io/scssphp/docs/#output-formatting
85 * @param string $formatterName
89 public function setFormatter($formatterName)
91 return parent::setFormatter($formatterName);