Skip to content

Commit

Permalink
vite prefetch for faster site experience
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinecraft committed Dec 12, 2024
1 parent 45b2085 commit 7188dea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\ServiceProvider;
use Laravel\Pulse\Facades\Pulse;
use Illuminate\Support\Facades\Vite;
use DB;

class AppServiceProvider extends ServiceProvider
Expand Down Expand Up @@ -57,6 +58,11 @@ public function boot()
Queue::after(function (JobProcessed $event) {
Cache::set('queue_last_processed', now());
});

// Vite Prefetch
if (config('inertia.vite_prefetch')) {
Vite::prefetch(concurrency: 3);
}
}

private function configureCommands()
Expand Down
11 changes: 11 additions & 0 deletions config/inertia.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,15 @@

],


/*
|--------------------------------------------------------------------------
| Vite Prefetch
|--------------------------------------------------------------------------
|
| This option configures if Vite should prefetch assets for Inertia pages.
|
*/
'vite_prefetch' => env('VITE_PREFETCH', false),

];

0 comments on commit 7188dea

Please sign in to comment.