diff --git a/modules/cms/components/Resources.php b/modules/cms/components/Resources.php index 4aba8d953..251e93096 100644 --- a/modules/cms/components/Resources.php +++ b/modules/cms/components/Resources.php @@ -25,6 +25,11 @@ class Resources extends ComponentBase */ public $lessDir = 'less'; + /** + * @var string The default SASS directory + */ + public $sassDir = 'sass'; + /** * @return array */ @@ -54,6 +59,12 @@ class Resources extends ComponentBase 'type' => 'stringList', 'showExternalParam' => false ], + 'sass' => [ + 'title' => 'SASS', + 'description' => 'SASS file(s) in the assets/sass folder', + 'type' => 'stringList', + 'showExternalParam' => false + ], 'css' => [ 'title' => 'CSS', 'description' => 'Stylesheet file(s) in the assets/css folder', @@ -73,6 +84,7 @@ class Resources extends ComponentBase { $this->assetPath = $this->guessAssetPath(); $this->jsDir = $this->guessAssetDirectory(['js', 'javascript'], $this->jsDir); + $this->sassDir = $this->guessAssetDirectory(['sass', 'scss'], $this->sassDir); } public function onRun() @@ -93,6 +105,14 @@ class Resources extends ComponentBase $less += array_map([$this, 'prefixLess'], (array) $assets); } + /* + * SASS + */ + $sass = []; + if ($assets = $this->property('sass')) { + $sass += array_map([$this, 'prefixSass'], (array) $assets); + } + /* * CSS */ @@ -109,6 +129,10 @@ class Resources extends ComponentBase $this->addCss(CombineAssets::combine($less, $this->assetPath)); } + if (count($sass)) { + $this->addCss(CombineAssets::combine($sass, $this->assetPath)); + } + if (count($css)) { $this->addCss(CombineAssets::combine($css, $this->assetPath)); } @@ -138,6 +162,11 @@ class Resources extends ComponentBase return $this->lessDir.'/'.trim($value); } + protected function prefixSass($value) + { + return $this->sassDir.'/'.trim($value); + } + protected function guessAssetDirectory(array $possible, $default = null) { foreach ($possible as $option) {