From 9d6aec77b4ba47ee35230acfe52864a8a5b64a1d Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Tue, 30 Nov 2021 09:06:39 +0100 Subject: [PATCH] feat: build css if missing Signed-off-by: Thierry Bugier --- inc/common.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/inc/common.class.php b/inc/common.class.php index 77e1e0181..2cc28c3d8 100644 --- a/inc/common.class.php +++ b/inc/common.class.php @@ -565,6 +565,20 @@ public static function getCssFilename() : string { if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) { return 'css/styles.scss'; } + $scssFile = Plugin::getPhpDir('formcreator', false) . '/css/styles.scss'; + $compiled_path = Plugin::getPhpDir('formcreator') . "/css_compiled/" . basename($scssFile, '.scss') . ".min.css"; + if (!file_exists($compiled_path)) { + $css = Html::compileScss( + [ + 'file' => $scssFile, + 'nocache' => true, + 'debug' => true, + ] + ); + if (strlen($css) === @file_put_contents($compiled_path, $css)) { + return 'css/styles.scss'; + } + } return 'css_compiled/styles.min.css'; }