diff --git a/packages/framework/src/Facades/Vite.php b/packages/framework/src/Facades/Vite.php index 2ff21c2ab67..d45c21aaf24 100644 --- a/packages/framework/src/Facades/Vite.php +++ b/packages/framework/src/Facades/Vite.php @@ -42,7 +42,7 @@ protected static function checkIfViteWasEnabledViaTheServeCommand(): bool protected static function isCssPath(string $path): bool { - return str_ends_with($path, '.css'); + return preg_match('/\.(css|less|sass|scss|styl|stylus|pcss|postcss)$/', $path) === 1; } protected static function isJsPath(string $path): bool diff --git a/packages/framework/tests/Unit/Facades/ViteFacadeTest.php b/packages/framework/tests/Unit/Facades/ViteFacadeTest.php index 27397aeac9c..fa10f82300e 100644 --- a/packages/framework/tests/Unit/Facades/ViteFacadeTest.php +++ b/packages/framework/tests/Unit/Facades/ViteFacadeTest.php @@ -98,4 +98,21 @@ public function testAssetsMethodGeneratesCorrectHtmlForMultipleFiles() $this->assertSame($expected, (string) $html); } + + /** + * @dataProvider cssFileExtensions + */ + public function testAssetsMethodSupportsAllCssFileExtensions(string $extension) + { + $html = Vite::assets(["resources/css/app.$extension"]); + + $expected = ''; + + $this->assertSame($expected, (string) $html); + } + + public static function cssFileExtensions(): array + { + return array_map(fn (string $ext): array => [$ext], ['css', 'less', 'sass', 'scss', 'styl', 'stylus', 'pcss', 'postcss']); + } }