class Illuminate / Foundation / Vite

Vite

Implements

Uses

Properties

protected

$nonce string|null

The Content Security Policy nonce to apply to all generated tags.

Default: null
protected

$integrityKey string|false

The key to check for integrity hashes within the manifest.

Default: 'integrity'
protected

$entryPoints array

The configured entry points.

Default: []
protected

$hotFile string|null

The path to the "hot" file.

Default: null
protected

$buildDirectory string

The path to the build directory.

Default: 'build'
protected

$manifestFilename string

The name of the manifest file.

Default: 'manifest.json'
protected

$scriptTagAttributesResolvers array

The script tag attributes resolvers.

Default: []
protected

$styleTagAttributesResolvers array

The style tag attributes resolvers.

Default: []
protected

$preloadTagAttributesResolvers array

The preload tag attributes resolvers.

Default: []
protected

$preloadedAssets array

The preloaded assets.

Default: []
protected static

$manifests array

The cached manifest files.

Default: []

Methods

public

preloadedAssets ( ) : array

Get the preloaded assets.

public

cspNonce ( ) : string|null

Get the Content Security Policy nonce applied to all generated tags.

public

useCspNonce ( $nonce ) : string

Generate or set a Content Security Policy nonce to apply to all generated tags.

Parameters

  • $nonce string|null
public

useIntegrityKey ( $key ) : $this

Use the given key to detect integrity hashes in the manifest.

Parameters

  • $key string|false
public

withEntryPoints ( $entryPoints ) : $this

Set the Vite entry points.

Parameters

  • $entryPoints array
public

useManifestFilename ( $filename ) : $this

Set the filename for the manifest file.

Parameters

  • $filename string
public

hotFile ( ) : string

Get the Vite "hot" file path.

public

useHotFile ( $path ) : $this

Set the Vite "hot" file path.

Parameters

  • $path string
public

useBuildDirectory ( $path ) : $this

Set the Vite build directory.

Parameters

  • $path string
public

useScriptTagAttributes ( $attributes ) : $this

Use the given callback to resolve attributes for script tags.

Parameters

  • $attributes callable|array
public

useStyleTagAttributes ( $attributes ) : $this

Use the given callback to resolve attributes for style tags.

Parameters

  • $attributes callable|array
public

usePreloadTagAttributes ( $attributes ) : $this

Use the given callback to resolve attributes for preload tags.

Parameters

  • $attributes callable|array|false
public

__invoke ( $entrypoints , $buildDirectory ) : HtmlString

Generate Vite tags for an entrypoint.

Parameters

  • $entrypoints string|string[]
  • $buildDirectory string|null
protected

makeTagForChunk ( $src , $url , $chunk , $manifest ) : string

Make tag for the given chunk.

Parameters

  • $src string
  • $url string
  • $chunk array|null
  • $manifest array|null
protected

makePreloadTagForChunk ( $src , $url , $chunk , $manifest ) : string

Make a preload tag for the given chunk.

Parameters

  • $src string
  • $url string
  • $chunk array
  • $manifest array
protected

resolveScriptTagAttributes ( $src , $url , $chunk , $manifest ) : array

Resolve the attributes for the chunks generated script tag.

Parameters

  • $src string
  • $url string
  • $chunk array|null
  • $manifest array|null
protected

resolveStylesheetTagAttributes ( $src , $url , $chunk , $manifest ) : array

Resolve the attributes for the chunks generated stylesheet tag.

Parameters

  • $src string
  • $url string
  • $chunk array|null
  • $manifest array|null
protected

resolvePreloadTagAttributes ( $src , $url , $chunk , $manifest ) : array|false

Resolve the attributes for the chunks generated preload tag.

Parameters

  • $src string
  • $url string
  • $chunk array
  • $manifest array
deprecated protected

makeTag ( $url ) : string

Generate an appropriate tag for the given URL in HMR mode.

Parameters

  • $url string
deprecated protected

makeScriptTag ( $url ) : string

Generate a script tag for the given URL.

Parameters

  • $url string
deprecated protected

makeStylesheetTag ( $url ) : string

Generate a stylesheet tag for the given URL in HMR mode.

Parameters

  • $url string
protected

makeScriptTagWithAttributes ( $url , $attributes ) : string

Generate a script tag with attributes for the given URL.

Parameters

  • $url string
  • $attributes array
protected

makeStylesheetTagWithAttributes ( $url , $attributes ) : string

Generate a link tag with attributes for the given URL.

Parameters

  • $url string
  • $attributes array
protected

isCssPath ( $path ) : bool

Determine whether the given path is a CSS file.

Parameters

  • $path string
protected

parseAttributes ( $attributes ) : array

Parse the attributes into key="value" strings.

Parameters

  • $attributes array
public

reactRefresh ( ) : HtmlString |void

Generate React refresh runtime script.

protected

hotAsset ( $asset ) : string

Get the path to a given asset when running in HMR mode.

public

asset ( $asset , $buildDirectory ) : string

Get the URL for an asset.

Parameters

  • $asset string
  • $buildDirectory string|null
public

content ( $asset , $buildDirectory ) : string

Get the content of a given asset.

Parameters

  • $asset string
  • $buildDirectory string|null
protected

assetPath ( $path , $secure ) : string

Generate an asset path for the application.

Parameters

  • $path string
  • $secure bool|null
protected

manifest ( $buildDirectory ) : array

Get the the manifest file for the given build directory.

Parameters

  • $buildDirectory string
protected

manifestPath ( $buildDirectory ) : string

Get the path to the manifest file for the given build directory.

Parameters

  • $buildDirectory string
public

manifestHash ( $buildDirectory ) : string|null

Get a unique hash representing the current manifest, or null if there is no manifest.

Parameters

  • $buildDirectory string|null
protected

chunk ( $manifest , $file ) : array

Get the chunk for the given entry point / asset.

Parameters

  • $manifest array
  • $file string
public

isRunningHot ( ) : bool

Determine if the HMR server is running.

public

toHtml ( ) : string

Get the Vite tag content as a string of HTML.