diff --git a/src/helpers/ManifestHelper.php b/src/helpers/ManifestHelper.php index ef80476..5ecad9f 100644 --- a/src/helpers/ManifestHelper.php +++ b/src/helpers/ManifestHelper.php @@ -164,6 +164,8 @@ public static function extractManifestTags(string $path, bool $asyncCss = true, } // Include any CSS tags $cssFiles = []; + $isCssEntry = str_contains(self::$manifest[$manifestKey]['file'] ?? '', '.css'); + self::extractCssFiles(self::$manifest, $manifestKey, $cssFiles); foreach ($cssFiles as $cssFile) { $tags[$cssFile] = [ @@ -174,6 +176,11 @@ public static function extractManifestTags(string $path, bool $asyncCss = true, ], $asyncCssOptions, $cssTagAttrs) ]; } + + // Remove duplicate script entry since this is CSS-like entry + if ($isCssOutputFile) { + unset($tags[$manifestKey]); + } } return $tags; @@ -219,8 +226,14 @@ protected static function extractCssFiles(array $manifest, string $manifestKey, if (!$entry) { return []; } + $entryFileName = $entry['file'] ?? ''; $cssFiles = array_merge($cssFiles, $entry['css'] ?? []); $imports = $entry['imports'] ?? []; + + if (str_contains($entryFileName, '.css')) { + $cssFiles[] = $entryFileName; + } + foreach ($imports as $import) { self::extractCssFiles($manifest, $import, $cssFiles); }