Skip to content

Commit

Permalink
[5.x] Eagerly prefetch assets (#1528)
Browse files Browse the repository at this point in the history
* Eagerly prefetch assets

* Update InstallCommand.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
timacdonald and taylorotwell authored Sep 4, 2024
1 parent b984a79 commit 7e9c149
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,13 @@ protected function installLivewireStack()
copy(__DIR__.'/../../stubs/resources/markdown/policy.md', resource_path('markdown/policy.md'));

// Service Providers...
copy(__DIR__.'/../../stubs/app/Providers/JetstreamServiceProvider.php', app_path('Providers/JetstreamServiceProvider.php'));
copy(__DIR__.'/../../stubs/app/Providers/JetstreamServiceProvider.php', $provider = app_path('Providers/JetstreamServiceProvider.php'));

$this->replaceInFile([
PHP_EOL.'use Illuminate\Support\Facades\Vite;',
PHP_EOL.PHP_EOL.' Vite::prefetch(concurrency: 3);',
], '', $provider);

ServiceProvider::addProviderToBootstrapFile('App\Providers\JetstreamServiceProvider');

// Models...
Expand Down Expand Up @@ -766,8 +772,8 @@ protected function runDatabaseMigrations()
/**
* Replace a given string within a given file.
*
* @param string $search
* @param string $replace
* @param string|array $search
* @param string $path
* @return void
*/
Expand Down
3 changes: 3 additions & 0 deletions stubs/app/Providers/JetstreamServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Providers;

use App\Actions\Jetstream\DeleteUser;
use Illuminate\Support\Facades\Vite;
use Illuminate\Support\ServiceProvider;
use Laravel\Jetstream\Jetstream;

Expand All @@ -24,6 +25,8 @@ public function boot(): void
$this->configurePermissions();

Jetstream::deleteUsersUsing(DeleteUser::class);

Vite::prefetch(concurrency: 3);
}

/**
Expand Down

0 comments on commit 7e9c149

Please sign in to comment.