final class Vite

Supports operations for Vite.

Methods

static string
csrfToken()

Extracts value of csrf_token from hidden element.

static bool
isDev()

Simple env-based dev check.

static bool
viteIsRunning(string $devBase = 'http://localhost:5173')

Check if Vite dev server is reachable.

static string
devTags(string $entry, string $devServer)

Adds dev tags.

static array|null
loadManifest()

Locate and decode the Vite manifest.

static string
prodTags(string $entry)

Adds production tags.

static string
tags(string $entry, string $devServer = 'http://localhost:5173')

Render script/link tags for a Vite entry.

Details

at line 16
static string csrfToken()

Extracts value of csrf_token from hidden element.

Return Value

string

The csrf_token.

at line 30
static bool isDev()

Simple env-based dev check.

Return Value

bool

at line 41
static bool viteIsRunning(string $devBase = 'http://localhost:5173')

Check if Vite dev server is reachable.

Parameters

string $devBase

URL for dev server.

Return Value

bool

True if running, otherwise false.

at line 56
static private string devTags(string $entry, string $devServer)

Adds dev tags.

Parameters

string $entry

Relative path from project root (e.g. 'resources/js/app.jsx')

string $devServer

URL for dev server.

Return Value

string

Script modules with tags.

at line 72
static private array|null loadManifest()

Locate and decode the Vite manifest.

Return Value

array|null

The Vite manifest.

at line 109
static private string prodTags(string $entry)

Adds production tags.

Parameters

string $entry

Relative path from project root (e.g. 'resources/js/app.jsx')

Return Value

string

The production tags.

at line 177
static string tags(string $entry, string $devServer = 'http://localhost:5173')

Render script/link tags for a Vite entry.

  • In dev (env=local/dev & dev server up), inject HMR client + raw module URL.
  • In prod (APP_ENV=production), always use manifest-based assets.

Parameters

string $entry

Relative path from project root (e.g. 'resources/js/app.jsx')

string $devServer

URL for dev server.

Return Value

string

Script/link tags for a Vite entry.