From: Tim Düsterhus Date: Wed, 3 Feb 2021 13:40:35 +0000 (+0100) Subject: Pass SCSS instead of files + invididualScss to StyleCompiler::compileStylesheet() X-Git-Tag: 5.4.0_Alpha_1~316^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f4a52c4c02ac5c788f98ebce434e4359023f03a7;p=GitHub%2FWoltLab%2FWCF.git Pass SCSS instead of files + invididualScss to StyleCompiler::compileStylesheet() --- diff --git a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php index c6cab51dc1..dcfdca70bf 100644 --- a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php +++ b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php @@ -19,8 +19,8 @@ use wcf\util\StyleUtil; /** * Provides access to the SCSS PHP compiler. * - * @author Alexander Ebert - * @copyright 2001-2020 WoltLab GmbH + * @author Tim Duesterhus, Alexander Ebert + * @copyright 2001-2021 WoltLab GmbH * @license GNU Lesser General Public License * @package WoltLabSuite\Core\System\Style */ @@ -162,11 +162,19 @@ final class StyleCompiler extends SingletonFactory $files[] = $customCustomSCSSFile; } + $scss = $this->bootstrap(); + foreach ($files as $file) { + $scss .= $this->prepareFile($file); + } + $scss .= $individualScss; + if (!empty($parameters['scss'])) { + $scss .= "\n" . $parameters['scss']; + } + try { $css = $this->compileStylesheet( - $files, - $variables, - $individualScss . (!empty($parameters['scss']) ? "\n" . $parameters['scss'] : ''), + $scss, + $variables ); $header = "/* stylesheet for '" . $styleName . "', generated on " . \gmdate('r') . " -- DO NOT EDIT */"; @@ -261,10 +269,18 @@ final class StyleCompiler extends SingletonFactory $parameters = ['scss' => '']; EventHandler::getInstance()->fireAction($this, 'compile', $parameters); + $scss = $this->bootstrap(); + foreach ($this->getFiles() as $file) { + $scss .= $this->prepareFile($file); + } + $scss .= $individualScss; + if (!empty($parameters['scss'])) { + $scss .= "\n" . $parameters['scss']; + } + $css = $this->compileStylesheet( - $this->getFiles(), - $variables, - $individualScss . (!empty($parameters['scss']) ? "\n" . $parameters['scss'] : '') + $scss, + $variables ); $header = "/* stylesheet for '" . $style->styleName . "', generated on " . \gmdate('r') . " -- DO NOT EDIT */"; @@ -314,10 +330,14 @@ final class StyleCompiler extends SingletonFactory $variables['style_image_path'] = "'../images/'"; + $scss = $this->bootstrap(); + foreach ($files as $file) { + $scss .= $this->prepareFile($file); + } + $css = $this->compileStylesheet( - $files, - $variables, - '' + $scss, + $variables ); // fix relative paths @@ -479,13 +499,11 @@ EOT; } /** - * Compiles the given SCSS files into one CSS stylesheet and returns it. + * Compiles the given SCSS into one CSS stylesheet and returns it. * - * @param string[] $files * @param string[] $variables - * @param string $individualScss */ - protected function compileStylesheet(array $files, array $variables, $individualScss): string + protected function compileStylesheet(string $scss, array $variables): string { foreach ($variables as &$value) { if (StringUtil::startsWith($value, '../')) { @@ -527,20 +545,9 @@ EOT; // convert into numeric value for comparison, e.g. `3.1` -> `31` $variables['apiVersion'] = \str_replace('.', '', $variables['apiVersion']); - // build SCSS bootstrap $compiler = $this->makeCompiler(); $compiler->setVariables($variables); - $scss = $this->bootstrap(); - foreach ($files as $file) { - $scss .= $this->prepareFile($file); - } - - // append individual CSS/SCSS - if ($individualScss) { - $scss .= $individualScss; - } - try { return $compiler->compile($scss); } catch (\Exception $e) {