Skip to content

Commit

Permalink
feat: build css if missing
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Dec 1, 2021
1 parent 86b56a3 commit 9d6aec7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions inc/common.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down

0 comments on commit 9d6aec7

Please sign in to comment.