MDL-69117 theme_boost: themedesigner source maps
This commit is contained in:
committed by
Andrew Nicols
parent
74160de2cb
commit
cce23499e6
+32
-3
@@ -1440,17 +1440,33 @@ class theme_config {
|
||||
|
||||
// TODO: MDL-62757 When changing anything in this method please do not forget to check
|
||||
// if the validate() method in class admin_setting_configthemepreset needs updating too.
|
||||
$cacheoptions = '';
|
||||
|
||||
$cachedir = make_localcache_directory('scsscache-' . $this->name, false);
|
||||
$cacheoptions = [];
|
||||
if ($themedesigner) {
|
||||
$scsscachedir = $CFG->localcachedir . '/scsscache/';
|
||||
$cacheoptions = array(
|
||||
'cacheDir' => $scsscachedir,
|
||||
'cacheDir' => $cachedir,
|
||||
'prefix' => 'scssphp_',
|
||||
'forceRefresh' => false,
|
||||
);
|
||||
} else {
|
||||
if (file_exists($cachedir)) {
|
||||
remove_directory($cachedir);
|
||||
}
|
||||
}
|
||||
|
||||
// Set-up the compiler.
|
||||
$compiler = new core_scss($cacheoptions);
|
||||
|
||||
if ($this->supports_source_maps($themedesigner)) {
|
||||
// Enable source maps.
|
||||
$compiler->setSourceMapOptions([
|
||||
'sourceMapBasepath' => str_replace('\\', '/', $CFG->dirroot),
|
||||
'sourceMapRootpath' => $CFG->wwwroot . '/'
|
||||
]);
|
||||
$compiler->setSourceMap($compiler::SOURCE_MAP_INLINE);
|
||||
}
|
||||
|
||||
$compiler->prepend_raw_scss($this->get_pre_scss_code());
|
||||
if (is_string($scss)) {
|
||||
$compiler->set_file($scss);
|
||||
@@ -2192,6 +2208,19 @@ class theme_config {
|
||||
$this->rtlmode = $inrtl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if source maps are supported
|
||||
*
|
||||
* @param bool $themedesigner True if theme designer is enabled.
|
||||
* @return boolean True if source maps are supported.
|
||||
*/
|
||||
public function supports_source_maps($themedesigner): bool {
|
||||
if (empty($this->rtlmode) && $themedesigner) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the theme is being served in RTL mode.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user