I'm trying to to compile scss from my plugin that I can then serve somehow.
compiling the scss isn't much of a problem, I just followed how themes do it which was something like:
function compile_scss($scssraw) { $cache = cache::make('block_myplugin', 'scss'); // definition in the db/cache.php raise_memory_limit(MEMORY_EXTRA); \core_php_time_limit::raise(300); $cachedir = make_localcache_directory('scsscache-myplugin-scss', false); $cacheoptions = []; if (file_exists($cachedir)) { remove_dir($cachedir); } $compiler = new core_scss($cacheoptions); $compiler->append_raw_scss($scssraw); try { // Compile! $compiled = $compiler->to_css(); // remove the previous cache $cache->delete($name); // minify and store $css = \core_minify::css($compiled); $cache->set($name, $css); } catch (\Exception $e) { $compiled = false; debugging('Error while compiling SCSS: ' . $e->getMessage(), DEBUG_DEVELOPER); } // Try to save memory. $compiler = null; unset($compiler); return $compiled; }
the function does create a file down in moodledata/cache/cachestore_file/scsscache-myplugin-scss/... I'd like this to be stored in a cache and have an url that I can serve it from in runtime scripts. But how do I serve that file from the cache? I presume I need a proxy script in by plugin, but I'm not sure how to write that or where to find an example or documentation on such. Can anybody help out?