N°2982 - Speed up SCSS themes compilation during setup - fix included files with same name and folder

This commit is contained in:
odain
2021-03-23 11:32:40 +01:00
parent 80cc850112
commit 7127c70ed6
4 changed files with 29 additions and 3 deletions

View File

@@ -772,8 +772,8 @@ CSS;
// Handle shortcut syntax : @import "typo" ;
// file matched: _typo.scss
$sShortCut = substr($sFilePath, strrpos($sFilePath, '/') + 1);
$sFilePath = str_replace($sShortCut, "_$sShortCut.scss", $sFilePath);
$sFileURI = str_replace($sShortCut, "_$sShortCut.scss", $sFileURI);
$sFilePath = static::ReplaceLastOccurrence($sShortCut, "_$sShortCut.scss", $sFilePath);
$sFileURI = static::ReplaceLastOccurrence($sShortCut, "_$sShortCut.scss", $sFileURI);
$sImportedFile = realpath($sFilePath);
}
@@ -799,6 +799,27 @@ CSS;
}
}
/**
* @param $search
* @param $replace
* @param $subject
*
* @since 3.0.0 N°2982
* Replaces last occurrence of the string
* @return string|string[]
*/
static function ReplaceLastOccurrence($sSearch, $sReplace, $sSubject)
{
$iPos = strrpos($sSubject, $sSearch);
if($iPos !== false)
{
$sSubject = substr_replace($sSubject, $sReplace, $iPos, strlen($sSearch));
}
return $sSubject;
}
/**
* @since 3.0.0 N°2982
* Used for testing purpose

View File

@@ -652,10 +652,14 @@ SCSS;
"sFileToFind" => "css/simple_import2.scss",
"aAllImports" => [$sFileToFind5]
],
"scss with @imports shortcut typography => _typography.scss" => [
"scss with @imports shortcut included_file3 => _included_file3.scss" => [
"sFileToFind" => "css/shortcut.scss",
"aAllImports" => ["css/_included_file3.scss", "css/included_scss/included_file4.scss"]
],
"scss with @imports shortcut same file and folder names => feature1/_feature1.scss" => [
"sFileToFind" => "css/shortcut2.scss",
"aAllImports" => ["css/feature1/_feature1.scss"]
],
"cross_reference & infinite loop" => [
"sFileToFind" => "css/cross_reference1.scss",
"aAllImports" => ["css/cross_reference2.scss"]

View File

@@ -0,0 +1 @@
@import 'feature1/feature1';