Skip to content

Commit

Permalink
Extract helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 8, 2024
1 parent 079913d commit ecbf8bd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/framework/src/Facades/Vite.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public static function assets(array $paths): HtmlString

foreach ($paths as $path) {
if (str_ends_with($path, '.css')) {
$html .= sprintf('<link rel="stylesheet" href="http://localhost:5173/%s">', $path);
$html .= static::formatStylesheetLink($path);
}

if (str_ends_with($path, '.js')) {
$html .= sprintf('<script src="http://localhost:5173/%s" type="module"></script>', $path);
$html .= static::formatScriptInclude($path);
}
}

Expand All @@ -37,4 +37,14 @@ protected static function checkIfViteWasEnabledViaTheServeCommand(): bool
{
return env('HYDE_SERVER_VITE') === 'enabled';
}

protected static function formatStylesheetLink(string $path): string
{
return sprintf('<link rel="stylesheet" href="http://localhost:5173/%s">', $path);
}

protected static function formatScriptInclude(string $path): string
{
return sprintf('<script src="http://localhost:5173/%s" type="module"></script>', $path);
}
}

0 comments on commit ecbf8bd

Please sign in to comment.