diff --git a/src/LivewireMaterialServiceProvider.php b/src/LivewireMaterialServiceProvider.php index 49e6604c..1df3de15 100644 --- a/src/LivewireMaterialServiceProvider.php +++ b/src/LivewireMaterialServiceProvider.php @@ -175,12 +175,14 @@ class LivewireMaterialServiceProvider extends ServiceProvider */ protected function registerShowcase(): void { + // Registered even with the showcase off: `php artisan view:cache` compiles every view in the + // package's namespace, the showcase's pages included, and must resolve there. + Blade::anonymousComponentPath(__DIR__.'/../resources/views/showcase/components', 'showcase'); + if (! config('livewire-material.showcase.enabled')) { return; } - Blade::anonymousComponentPath(__DIR__.'/../resources/views/showcase/components', 'showcase'); - if ($this->app->routesAreCached()) { return; } diff --git a/tests/Feature/ShowcaseTest.php b/tests/Feature/ShowcaseTest.php index 5e977f43..3f340746 100644 --- a/tests/Feature/ShowcaseTest.php +++ b/tests/Feature/ShowcaseTest.php @@ -71,6 +71,20 @@ it('does not mount the showcase when disabled', function () { $this->get('/material')->assertNotFound(); }); +it('compiles every package view with the showcase off, as view:cache does in production', function () { + rebootWithShowcase(false); + + $compiled = sys_get_temp_dir().'/livewire-material-view-cache-'.uniqid(); + config(['view.compiled' => $compiled]); + File::ensureDirectoryExists($compiled); + + try { + $this->artisan('view:cache')->assertSuccessful(); + } finally { + File::deleteDirectory($compiled); + } +}); + it('serves a symbol for the icon search', function () { $this->get('/material/symbols/filled/favorite.svg') ->assertOk()