Vite
class Vite implements Htmlable (View source)
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
protected string|null | $nonce | The Content Security Policy nonce to apply to all generated tags. |
|
protected string|false | $integrityKey | The key to check for integrity hashes within the manifest. |
|
protected array | $entryPoints | The configured entry points. |
|
protected string|null | $hotFile | The path to the "hot" file. |
|
protected string | $buildDirectory | The path to the build directory. |
|
protected string | $manifestFilename | The name of the manifest file. |
|
protected callable|null | $assetPathResolver | The custom asset path resolver. |
|
protected array | $scriptTagAttributesResolvers | The script tag attributes resolvers. |
|
protected array | $styleTagAttributesResolvers | The style tag attributes resolvers. |
|
protected array | $preloadTagAttributesResolvers | The preload tag attributes resolvers. |
|
protected array | $preloadedAssets | The preloaded assets. |
|
static protected array | $manifests | The cached manifest files. |
|
protected | $prefetchStrategy | The prefetching strategy to use. |
|
protected int | $prefetchConcurrently | The number of assets to load concurrently when using the "waterfall" strategy. |
|
protected string | $prefetchEvent | The name of the event that should trigger prefetching. The event must be dispatched on the |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Get the preloaded assets.
Get the Content Security Policy nonce applied to all generated tags.
Generate or set a Content Security Policy nonce to apply to all generated tags.
Use the given key to detect integrity hashes in the manifest.
Set the Vite entry points.
Merge additional Vite entry points with the current set.
Set the filename for the manifest file.
Resolve asset paths using the provided resolver.
Get the Vite "hot" file path.
Set the Vite "hot" file path.
Set the Vite build directory.
Use the given callback to resolve attributes for script tags.
Use the given callback to resolve attributes for style tags.
Use the given callback to resolve attributes for preload tags.
Eagerly prefetch assets.
Use the "waterfall" prefetching strategy.
Use the "aggressive" prefetching strategy.
Set the prefetching strategy.
Generate Vite tags for an entrypoint.
Make tag for the given chunk.
Make a preload tag for the given chunk.
Resolve the attributes for the chunks generated script tag.
Resolve the attributes for the chunks generated stylesheet tag.
Resolve the attributes for the chunks generated preload tag.
Generate a script tag with attributes for the given URL.
Generate a link tag with attributes for the given URL.
Determine whether the given path is a CSS file.
Parse the attributes into key="value" strings.
Generate React refresh runtime script.
Get the path to a given asset when running in HMR mode.
Get the URL for an asset.
Get the content of a given asset.
Generate an asset path for the application.
Get the manifest file for the given build directory.
Get the path to the manifest file for the given build directory.
Get a unique hash representing the current manifest, or null if there is no manifest.
Get the chunk for the given entry point / asset.
Get the nonce attribute for the prefetch script tags.
Determine if the HMR server is running.
Get the Vite tag content as a string of HTML.
Details
string
useCspNonce(string|null $nonce = null)
Generate or set a Content Security Policy nonce to apply to all generated tags.
$this
useIntegrityKey(string|false $key)
Use the given key to detect integrity hashes in the manifest.
$this
createAssetPathsUsing(callable|null $resolver)
Resolve asset paths using the provided resolver.
$this
useScriptTagAttributes($attributes)
Use the given callback to resolve attributes for script tags.
$this
useStyleTagAttributes($attributes)
Use the given callback to resolve attributes for style tags.
$this
usePreloadTagAttributes($attributes)
Use the given callback to resolve attributes for preload tags.
$this
useWaterfallPrefetching(int|null $concurrency = null)
Use the "waterfall" prefetching strategy.
HtmlString
__invoke(string|string[] $entrypoints, string|null $buildDirectory = null)
Generate Vite tags for an entrypoint.
protected string
makeTagForChunk(string $src, string $url, array|null $chunk, array|null $manifest)
Make tag for the given chunk.
protected string
makePreloadTagForChunk(string $src, string $url, array $chunk, array $manifest)
Make a preload tag for the given chunk.
protected array
resolveScriptTagAttributes(string $src, string $url, array|null $chunk, array|null $manifest)
Resolve the attributes for the chunks generated script tag.
protected array
resolveStylesheetTagAttributes(string $src, string $url, array|null $chunk, array|null $manifest)
Resolve the attributes for the chunks generated stylesheet tag.
protected array|false
resolvePreloadTagAttributes(string $src, string $url, array $chunk, array $manifest)
Resolve the attributes for the chunks generated preload tag.
protected string
makeTag(string $url)
deprecated
deprecated Will be removed in a future Laravel version.
Generate an appropriate tag for the given URL in HMR mode.
protected string
makeScriptTag(string $url)
deprecated
deprecated Will be removed in a future Laravel version.
Generate a script tag for the given URL.
protected string
makeStylesheetTag(string $url)
deprecated
deprecated Will be removed in a future Laravel version.
Generate a stylesheet tag for the given URL in HMR mode.
protected string
makeScriptTagWithAttributes(string $url, array $attributes)
Generate a script tag with attributes for the given URL.
protected string
makeStylesheetTagWithAttributes(string $url, array $attributes)
Generate a link tag with attributes for the given URL.
protected string
assetPath(string $path, bool|null $secure = null)
Generate an asset path for the application.
protected array
manifest(string $buildDirectory)
Get the manifest file for the given build directory.
protected string
manifestPath(string $buildDirectory)
Get the path to the manifest file for the given build directory.
string|null
manifestHash(string|null $buildDirectory = null)
Get a unique hash representing the current manifest, or null if there is no manifest.
protected array
chunk(array $manifest, string $file)
Get the chunk for the given entry point / asset.