Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Allow configurable less and scss import paths #7646

Open
wants to merge 2 commits into
base: 3.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions system/modules/core/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,11 @@
'SLIMBOX' => '1.8'
);

/**
* Register LESS/SCSS import paths
*/
$GLOBALS['TL_SCSSLESS_PATHS'] = array();


/**
* Other global arrays
Expand Down
12 changes: 12 additions & 0 deletions system/modules/core/library/Contao/Combiner.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ protected function handleScssLess($content, $arrFile)
TL_ROOT . '/vendor/contao-components/compass/css'
));

foreach ($GLOBALS['TL_SCSSLESS_PATHS'] as $strScssLessPath)
{
$strImportPath = ltrim($strScssLessPath, '/\\');
$objCompiler->addImportPath(TL_ROOT . '/' . $strImportPath);
}

$objCompiler->setFormatter((\Config::get('debugMode') ? 'Leafo\ScssPhp\Formatter\Expanded' : 'Leafo\ScssPhp\Formatter\Compressed'));

return $this->fixPaths($objCompiler->compile($content), $arrFile);
Expand All @@ -354,6 +360,12 @@ protected function handleScssLess($content, $arrFile)
'import_dirs' => array(TL_ROOT . '/' . $strPath => $strPath)
);

foreach ($GLOBALS['TL_SCSSLESS_PATHS'] as $strScssLessPath)
{
$strImportPath = ltrim($strScssLessPath, '/\\');
$arrOptions['import_dirs'][] = array(TL_ROOT . '/' . $strImportPath => $strImportPath);
}

$objParser = new \Less_Parser($arrOptions);
$objParser->parse($content);

Expand Down