Skip to content

Commit

Permalink
[1.x] Vite preloading (#196)
Browse files Browse the repository at this point in the history
* preloading

* require latest laravel version
  • Loading branch information
timacdonald authored Oct 24, 2022
1 parent 2e72648 commit 4762aee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"illuminate/validation": "^9.21"
},
"conflict": {
"laravel/framework": "<9.19.0"
"laravel/framework": "<9.37.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 3 additions & 1 deletion src/Console/InstallsInertiaStacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected function installInertiaVueStack()

// Middleware...
$this->installMiddlewareAfter('SubstituteBindings::class', '\App\Http\Middleware\HandleInertiaRequests::class');
$this->installMiddlewareAfter('\App\Http\Middleware\HandleInertiaRequests::class', '\Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class');

copy(__DIR__.'/../../stubs/inertia-common/app/Http/Middleware/HandleInertiaRequests.php', app_path('Http/Middleware/HandleInertiaRequests.php'));

Expand Down Expand Up @@ -153,12 +154,13 @@ protected function installInertiaReactStack()

// Middleware...
$this->installMiddlewareAfter('SubstituteBindings::class', '\App\Http\Middleware\HandleInertiaRequests::class');
$this->installMiddlewareAfter('\App\Http\Middleware\HandleInertiaRequests::class', '\Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class');

copy(__DIR__.'/../../stubs/inertia-common/app/Http/Middleware/HandleInertiaRequests.php', app_path('Http/Middleware/HandleInertiaRequests.php'));

// Views...
copy(__DIR__.'/../../stubs/inertia-common/resources/views/app.blade.php', resource_path('views/app.blade.php'));
$this->replaceInFile("@vite('resources/js/app.js')", '@viteReactRefresh'.PHP_EOL." @vite('resources/js/app.jsx')", resource_path('views/app.blade.php'));
$this->replaceInFile("@vite(\"resources/js/Pages/{\$page['component']}.vue\")", '@viteReactRefresh'.PHP_EOL." @vite(\"resources/js/Pages/{\$page['component']}.jsx\")", resource_path('views/app.blade.php'));

// Components + Pages...
(new Filesystem)->ensureDirectoryExists(resource_path('js/Components'));
Expand Down
2 changes: 1 addition & 1 deletion stubs/inertia-common/resources/views/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<!-- Scripts -->
@routes
@vite('resources/js/app.js')
@vite("resources/js/Pages/{$page['component']}.vue")
@inertiaHead
</head>
<body class="font-sans antialiased">
Expand Down

0 comments on commit 4762aee

Please sign in to comment.