Skip to content
Snippets Groups Projects
Commit de5cfa49 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by David Siegfried
Browse files

fix integration of scss php compiler, fixes #1574

Closes #1574

Merge request studip/studip!1004
parent 4b3fec9a
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ use StudipCacheFactory; ...@@ -6,7 +6,7 @@ use StudipCacheFactory;
use Studip; use Studip;
use ScssPhp\ScssPhp\Compiler as ScssCompiler; use ScssPhp\ScssPhp\Compiler as ScssCompiler;
use ScssPhp\ScssPhp\Formatter; use ScssPhp\ScssPhp\OutputStyle;
/** /**
* SCSS Compiler for assets. * SCSS Compiler for assets.
...@@ -48,7 +48,7 @@ class SASSCompiler implements Compiler ...@@ -48,7 +48,7 @@ class SASSCompiler implements Compiler
* core system can be used. This includes colors and icons. * core system can be used. This includes colors and icons.
* *
* @param String $input Scss content to compile * @param String $input Scss content to compile
* @param Array $variables Additional variables for the LESS compilation * @param array $variables Additional variables for the LESS compilation
* @return String containing the generated CSS * @return String containing the generated CSS
*/ */
public function compile($input, array $variables = []) public function compile($input, array $variables = [])
...@@ -59,14 +59,14 @@ class SASSCompiler implements Compiler ...@@ -59,14 +59,14 @@ class SASSCompiler implements Compiler
$compiler = new ScssCompiler(); $compiler = new ScssCompiler();
$compiler->addImportPath("{$GLOBALS['STUDIP_BASE_PATH']}/resources/"); $compiler->addImportPath("{$GLOBALS['STUDIP_BASE_PATH']}/resources/");
$compiler->setVariables($variables); $compiler->addVariables($variables);
if (Studip\ENV === 'production') { if (Studip\ENV === 'production') {
$compiler->setFormatter(Formatter\Crunched::class); $compiler->setOutputStyle(OutputStyle::COMPRESSED);
} else { } else {
$compiler->setFormatter(Formatter\Expanded::class); $compiler->setOutputStyle(OutputStyle::EXPANDED);
$compiler->setLineNumberStyle(ScssCompiler::LINE_COMMENTS); $compiler->setSourceMap(ScssCompiler::SOURCE_MAP_INLINE);
} }
$css = $compiler->compile($scss); $css = $compiler->compileString($scss)->getCss();
$css = preg_replace('~/\*.*?\*/~s', '', $css); $css = preg_replace('~/\*.*?\*/~s', '', $css);
$css = trim($css); $css = trim($css);
return $css; return $css;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment