Skip to content

Commit

Permalink
Merge pull request #2 from digizijn/assets-fix
Browse files Browse the repository at this point in the history
#963804 SASS compiler genereert teveel assets
  • Loading branch information
RdeWilde authored Jun 25, 2020
2 parents e10e470 + 9301111 commit 045ed35
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions SassHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,18 +543,31 @@ protected function setImportPaths($paths) {
*/
protected function saveParsedFilesInfoToCache($sourcePath)
{
$parsedFiles = $this->compiler->getParsedFiles(); // FIXME
$parsedFiles = $this->compiler->getParsedFiles();
$parsedFiles[$sourcePath] = filemtime($sourcePath);

$info = $this->getCompiledInfo(
$parsedFiles,
$this->autoAddCurrentDirectoryAsImportPath,
$this->compiler->getImportPaths(),
$this->compilerOutputFormatting
);

$pathInfo = $info;
unset($pathInfo['compiledFiles']);
$this->cacheSet($this->getCacheCompiledPrefix() . $sourcePath.'-'.md5(serialize($pathInfo)), $info);
}


public function getCompiledInfo(array $parsedFiles = [], bool $autoAddCurrentDirectoryAsImportPath = true, array $importPaths = [], $compilerOutputFormatting = 'nested') {
$info = array(
'compiledFiles' => $parsedFiles,
'autoAddCurrentDirectoryAsImportPath'
=> $this->autoAddCurrentDirectoryAsImportPath,
'importPaths' => $this->compiler->getImportPaths(),
'compilerOutputFormatting' => $this->compilerOutputFormatting,
'autoAddCurrentDirectoryAsImportPath' => $autoAddCurrentDirectoryAsImportPath,
'importPaths' => $importPaths,
'compilerOutputFormatting' => $compilerOutputFormatting,
);

$this->cacheSet($this->getCacheCompiledPrefix() . $sourcePath, $info);
return $info;
}

/**
Expand Down Expand Up @@ -611,8 +624,20 @@ protected function isCompilationNeeded($path)
*/
protected function isLastCompilationEnvironmentChanged($path)
{
$parsedFiles = $this->compiler->getParsedFiles();
$parsedFiles[$path] = filemtime($path);

$info = $this->getCompiledInfo(
$parsedFiles,
$this->autoAddCurrentDirectoryAsImportPath,
$this->compiler->getImportPaths(),
$this->compilerOutputFormatting
);

$pathInfo = $info;
unset($pathInfo['compiledFiles']);
$compiledInfo = $this->cacheGet(
$this->getCacheCompiledPrefix() . $path
$this->getCacheCompiledPrefix() . $path . '-'. md5(serialize($pathInfo))
);

$fieldsToCheckForChangedValue = array(
Expand All @@ -628,7 +653,7 @@ protected function isLastCompilationEnvironmentChanged($path)

if (
!isset($compiledInfo['importPaths']) or
$compiledInfo['importPaths'] !== $this->compiler->getImportPaths()
$compiledInfo['importPaths'] != $this->compiler->getImportPaths()
) {
return true;
}
Expand Down

0 comments on commit 045ed35

Please sign in to comment.