Search by

goognet / vite-plain-html

thimarsola

Makes Laravel's Vite helper emit plain HTML link tags, without the XHTML style slash.

Package info

github.com/Goognet/vite-plain-html

pkg:composer/goognet/vite-plain-html

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-09-18 12:41 UTC

This package is auto-updated.

Last update: 2026-09-18 12:46:31 UTC


README

Makes Laravel's Vite helper emit plain HTML link tags, without the XHTML style slash.

Laravel's @vite directive hardcodes the terminator on every link tag it prints:

<link rel="preload" as="style" href="/build/assets/app-abc123.css" />
<link rel="stylesheet" href="/build/assets/app-abc123.css" />

This package makes it print:

<link rel="preload" as="style" href="/build/assets/app-abc123.css">
<link rel="stylesheet" href="/build/assets/app-abc123.css">

Installation

composer require goognet/vite-plain-html

That is the whole setup. The service provider is auto-discovered, and your views keep calling @vite(...) as they do today.

Note this is a runtime dependency, not a dev one: the tags are generated on every request.

How it works

Illuminate\Foundation\Vite builds its link tags in three protected methods, each ending in a hardcoded ' />':

method tag
makePreloadTagForChunk <link rel="preload">
makeStylesheetTagWithAttributes <link rel="stylesheet">
renderFontPreloads <link rel="preload" as="font">, from @vite fonts

There is no option for it — useStyleTagAttributes() and usePreloadTagAttributes() only add attributes.

So this package subclasses the helper and rebinds it in the container. Each override hands the work to Laravel and rewrites the terminator on the way out, so none of Laravel's attribute logic is copied here and an upgrade cannot leave a stale copy of it behind:

protected function makeStylesheetTagWithAttributes($url, $attributes)
{
    return PlainHtml::tags(parent::makeStylesheetTagWithAttributes($url, $attributes));
}

The terminator is only rewritten at the end of a line, so a /> inside an attribute value is left alone.

Script tags are untouched — Laravel already prints those as <script ...></script>.

Requirements

  • PHP 8.3+
  • Laravel 13

Laravel 12 and earlier have the same two link tag methods but no renderFontPreloads, so this package targets 13 only.

License

MIT. See LICENSE.md.