diff --git a/config/utils.php b/config/utils.php index e9eb877..4bf8765 100644 --- a/config/utils.php +++ b/config/utils.php @@ -28,4 +28,8 @@ 'defaultView' => env('UTILS_PAGINATOR_VIEW', 'pagination::tailwind'), 'defaultSimpleView' => env('UTILS_PAGINATOR_SIMPLE_VIEW', 'pagination::simple-tailwind'), ], + + 'vite' => [ + 'strategy' => env('UTILS_VITE_STRATEGY', 'aggressive'), + ], ]; diff --git a/src/UtilsServiceProvider.php b/src/UtilsServiceProvider.php index 8530a8d..b6edea4 100644 --- a/src/UtilsServiceProvider.php +++ b/src/UtilsServiceProvider.php @@ -9,6 +9,7 @@ use Illuminate\Pagination\Paginator; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\URL; +use Illuminate\Support\Facades\Vite; use Illuminate\Support\ServiceProvider; class UtilsServiceProvider extends ServiceProvider @@ -37,6 +38,7 @@ public function boot() $this->bootSchema(); $this->bootHttps(); $this->bootPaginator(); + $this->bootVite(); } /** @@ -126,4 +128,16 @@ private function bootPaginator() Paginator::defaultSimpleView($paginatorDefaultSimpleView); } } + + /** + * Bootstrap vite. + * + * @return void + */ + private function bootVite() + { + if (class_exists(Vite::class) && method_exists(Vite::getFacadeRoot(), 'usePrefetchStrategy')) { + Vite::usePrefetchStrategy(config('utils.vite.strategy')); + } + } }