Skip to content

Commit

Permalink
Merge pull request #5 from datalogix/feat-vite-strategy
Browse files Browse the repository at this point in the history
Add vite strategy
  • Loading branch information
ricardogobbosouza authored Dec 13, 2024
2 parents 1bca393 + f6f034c commit 3f3c6df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
],
];
14 changes: 14 additions & 0 deletions src/UtilsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -37,6 +38,7 @@ public function boot()
$this->bootSchema();
$this->bootHttps();
$this->bootPaginator();
$this->bootVite();
}

/**
Expand Down Expand Up @@ -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'));
}
}
}

0 comments on commit 3f3c6df

Please sign in to comment.