diff --git a/src/Assets.php b/src/Assets.php index a93523b..2a62264 100644 --- a/src/Assets.php +++ b/src/Assets.php @@ -70,7 +70,7 @@ public function inject(array|string $entrypoint, array $customOptions = []): voi add_action($action, function () use ($entries, $options) { array_map(function($entry) use ($options) { - $tag = str_ends_with($entry, '.css') || str_ends_with($entry, '.scss') + $tag = $this->isStylesheet($entry) ? array_key_first($this->getStyleTags($entry, $options)) : $this->getScriptTag($entry, $options); @@ -216,4 +216,17 @@ private function mergeOptions(array $options = []) $options ); } + + /** + * Determines wether a file is a stylesheet based on its extension + * + * @param string $entry + * @return bool + */ + private function isStylesheet(string $entry) + { + $styleSheets = ['.css', '.less', '.scss', '.styl']; + + return in_array(pathinfo($entry, PATHINFO_EXTENSION), $styleSheets); + } }