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