Last active
May 7, 2021 17:46
-
-
Save timkelty/57810962cfb8f66126168eb6daf5a310 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function extractCssFiles(array $manifest, string $manifestKey): array | |
{ | |
$entry = $manifest[$manifestKey] ?? null; | |
if (!$entry) { | |
return []; | |
} | |
$cssFiles = array_values($entry['css'] ?? []); | |
$imports = array_merge($entry['imports'] ?? [], $entry['dynamicImports'] ?? []); | |
$importFiles = array_map(function ($manifestKey) use ($manifest, $manifestKey) { | |
return $this->extractCssFiles($manifest, $manifestKey); | |
}, $imports); | |
array_push($cssFiles, ...$importFiles); | |
return array_unique($cssFiles); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function extractCssFiles(array $manifest, string $manifestKey): array | |
{ | |
$entry = $manifest[$manifestKey] ?? null; | |
if (!$entry) { | |
return []; | |
} | |
$cssFiles = array_values($entry['css'] ?? []); | |
$imports = array_merge($entry['imports'] ?? [], $entry['dynamicImports'] ?? []); | |
return array_reduce($imports, function ($cssFiles, $manifestKey) use ($manifest) { | |
return array_unique(array_merge($cssFiles, $this->extractCssFiles($manifest, $manifestKey))); | |
}, $cssFiles); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment