Skip to content

Commit

Permalink
Merge pull request #110 from Jubeki/add-vitejs-autorefresh
Browse files Browse the repository at this point in the history
Add vitejs autorefresh to error page
  • Loading branch information
freekmurze authored Sep 16, 2022
2 parents ebf7c57 + 6b73c2a commit 192962f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"ext-json": "*",
"ext-mbstring": "*",
"monolog/monolog": "^2.3",
"spatie/ignition": "^1.2.4",
"spatie/ignition": "^1.4.1",
"spatie/flare-client-php": "^1.0.1",
"symfony/console": "^5.0|^6.0",
"symfony/var-dumper": "^5.0|^6.0",
"illuminate/support": "^8.77|^9.0"
"illuminate/support": "^8.77|^9.27"
},
"require-dev": {
"filp/whoops": "^2.14",
Expand Down
12 changes: 12 additions & 0 deletions src/Renderers/ErrorPageRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ class ErrorPageRenderer
{
public function render(Throwable $throwable): void
{
$vitejsAutoRefresh = '';

if (class_exists('Illuminate\Foundation\Vite')) {

$vite = app(\Illuminate\Foundation\Vite::class);

if (is_file($vite->hotFile())) {
$vitejsAutoRefresh = $vite->__invoke([]);
}
}

app(Ignition::class)
->resolveDocumentationLink(
fn (Throwable $throwable) => (new LaravelDocumentationLinkFinder())->findLinkForThrowable($throwable)
Expand All @@ -25,6 +36,7 @@ public function render(Throwable $throwable): void
->setContextProviderDetector(new LaravelContextProviderDetector())
->setSolutionTransformerClass(LaravelSolutionTransformer::class)
->applicationPath(base_path())
->addCustomHtmlToHead($vitejsAutoRefresh)
->renderException($throwable);
}
}

0 comments on commit 192962f

Please sign in to comment.