Skip to content

Commit de2d6d4

Browse files
feat(vite): make which extensions vite discovers configurable (#1375)
1 parent 9d70157 commit de2d6d4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/vite/src/ViteConfig.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function __construct(
2525
public string $bridgeFileName = 'vite-tempest',
2626
public string $manifest = 'manifest.json',
2727
public array $entrypoints = [],
28+
public array $discoverableExtensions = ['ts', 'tsx', 'js', 'jsx', 'css'],
2829
) {}
2930

3031
public function addEntrypoint(string $path): void

packages/vite/src/ViteDiscovery.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Tempest\Vite\ViteConfig;
1313

1414
use function Tempest\Support\str;
15-
use function Tempest\Support\Str\ends_with;
1615

1716
final class ViteDiscovery implements Discovery, DiscoversPath
1817
{
@@ -29,7 +28,7 @@ public function discover(DiscoveryLocation $location, ClassReflector $class): vo
2928

3029
public function discoverPath(DiscoveryLocation $location, string $path): void
3130
{
32-
if (! ends_with($path, ['.ts', '.css', '.js'])) {
31+
if (! in_array(pathinfo($path, PATHINFO_EXTENSION), $this->viteConfig->discoverableExtensions, strict: true)) {
3332
return;
3433
}
3534

0 commit comments

Comments
 (0)