diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2017-03-09 20:29:50 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-03-09 20:29:50 +0100 |
commit | 57be594f1fa67ae02209a68330ecf711d0b2e9a2 (patch) | |
tree | ba85572a53315f4320dd152ef32e41b7c3d99c9b | |
parent | 6d10a2aece9ab4cce0f57f20594b9fcb9372a794 (diff) | |
download | nextcloud-server-57be594f1fa67ae02209a68330ecf711d0b2e9a2.tar.gz nextcloud-server-57be594f1fa67ae02209a68330ecf711d0b2e9a2.zip |
Allow using import in sass files
This allows us to combine multiple sass files that we have to always
load together anyway.
Fixes #3389
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r-- | lib/private/Template/SCSSCacher.php | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index d6f5a2c6fd3..744ea80761e 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -103,10 +103,17 @@ class SCSSCacher { private function isCached($fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $path) { try{ $cachedFile = $folder->getFile($fileNameCSS); - if( $cachedFile->getMTime() > filemtime($path.'/'.$fileNameSCSS) - && $cachedFile->getSize() > 0 ) { - return true; + if ($cachedFile->getSize() > 0) { + $depFile = $folder->getFile($fileNameCSS . '.deps'); + $deps = json_decode($depFile->getContent(), true); + + foreach ($deps as $file=>$mtime) { + if (!file_exists($file) || filemtime($file) > $mtime) { + return false; + } + } } + return true; } catch(NotFoundException $e) { return false; } @@ -140,6 +147,13 @@ class SCSSCacher { $cachedfile = $folder->newFile($fileNameCSS); } + $depFileName = $fileNameCSS . '.deps'; + try { + $depFile = $folder->getFile($depFileName); + } catch (NotFoundException $e) { + $depFile = $folder->newFile($depFileName); + } + // Compile try { $compiledScss = $scss->compile('@import "'.$fileNameSCSS.'";'); @@ -150,6 +164,7 @@ class SCSSCacher { try { $cachedfile->putContent($this->rebaseUrls($compiledScss, $webDir)); + $depFile->putContent(json_encode($scss->getParsedFiles())); $this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']); return true; } catch(NotFoundException $e) { |