On this page
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 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. |
Methods
static void | macro(string $name, object|callable $macro) Register a custom macro. |
from Macroable |
static void | mixin(object $mixin, bool $replace = true) Mix another object into the class. |
from Macroable |
static bool | hasMacro(string $name) Checks if macro is registered. |
from Macroable |
static void | flushMacros() Flush the existing macros. |
from Macroable |
static mixed | __callStatic(string $method, array $parameters) Dynamically handle calls to the class. |
from Macroable |
mixed | __call(string $method, array $parameters) Dynamically handle calls to the class. |
from Macroable |
array | preloadedAssets() Get the preloaded assets. |
|
string|null | cspNonce() Get the Content Security Policy nonce applied to all generated tags. |
|
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 | withEntryPoints(array $entryPoints) Set the Vite entry points. |
|
$this | useManifestFilename(string $filename) Set the filename for the manifest file. |
|
string | hotFile() Get the Vite "hot" file path. |
|
$this | useHotFile(string $path) Set the Vite "hot" file path. |
|
$this | useBuildDirectory(string $path) Set the Vite build directory. |
|
$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. |
|
HtmlString | __invoke(string|string[] $entrypoints, string|null $buildDirectory = null) Generate Vite tags for an entrypoint. |
|
string | makeTagForChunk(string $src, string $url, array|null $chunk, array|null $manifest) Make tag for the given chunk. |
|
string | makePreloadTagForChunk(string $src, string $url, array $chunk, array $manifest) Make a preload tag for the given chunk. |
|
array | resolveScriptTagAttributes(string $src, string $url, array|null $chunk, array|null $manifest) Resolve the attributes for the chunks generated script tag. |
|
array | resolveStylesheetTagAttributes(string $src, string $url, array|null $chunk, array|null $manifest) Resolve the attributes for the chunks generated stylesheet tag. |
|
array|false | resolvePreloadTagAttributes(string $src, string $url, array $chunk, array $manifest) Resolve the attributes for the chunks generated preload tag. |
|
string | makeTag(string $url) deprecated Generate an appropriate tag for the given URL in HMR mode. |
|
string | makeScriptTag(string $url) deprecated Generate a script tag for the given URL. |
|
string | makeStylesheetTag(string $url) deprecated Generate a stylesheet tag for the given URL in HMR mode. |
|
string | makeScriptTagWithAttributes(string $url, array $attributes) Generate a script tag with attributes for the given URL. |
|
string | makeStylesheetTagWithAttributes(string $url, array $attributes) Generate a link tag with attributes for the given URL. |
|
bool | isCssPath(string $path) Determine whether the given path is a CSS file. |
|
array | parseAttributes(array $attributes) Parse the attributes into key="value" strings. |
|
HtmlString|void | reactRefresh() Generate React refresh runtime script. |
|
string | hotAsset($asset) Get the path to a given asset when running in HMR mode. |
|
string | asset(string $asset, string|null $buildDirectory = null) Get the URL for an asset. |
|
string | assetPath(string $path, bool|null $secure = null) Generate an asset path for the application. |
|
array | manifest(string $buildDirectory) Get the the manifest file for the given build directory. |
|
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. |
|
array | chunk(array $manifest, string $file) Get the chunk for the given entry point / asset. |
|
bool | isRunningHot() Determine if the HMR server is running. |
|
string | toHtml() Get the Vite tag content as a string of HTML. |
Details
static void macro(string $name, object|callable $macro)
Register a custom macro.
static void mixin(object $mixin, bool $replace = true)
Mix another object into the class.
static bool hasMacro(string $name)
Checks if macro is registered.
static void flushMacros()
Flush the existing macros.
static mixed __callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed __call(string $method, array $parameters)
Dynamically handle calls to the class.
array preloadedAssets()
Get the preloaded assets.
string|null cspNonce()
Get the Content Security Policy nonce applied to all generated tags.
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 withEntryPoints(array $entryPoints)
Set the Vite entry points.
$this useManifestFilename(string $filename)
Set the filename for the manifest file.
string hotFile()
Get the Vite "hot" file path.
$this useHotFile(string $path)
Set the Vite "hot" file path.
$this useBuildDirectory(string $path)
Set the Vite build directory.
$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.
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 bool isCssPath(string $path)
Determine whether the given path is a CSS file.
protected array parseAttributes(array $attributes)
Parse the attributes into key="value" strings.
HtmlString|void reactRefresh()
Generate React refresh runtime script.
protected string hotAsset($asset)
Get the path to a given asset when running in HMR mode.
string asset(string $asset, string|null $buildDirectory = null)
Get the URL for an asset.
protected string assetPath(string $path, bool|null $secure = null)
Generate an asset path for the application.
protected array manifest(string $buildDirectory)
Get the 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.
bool isRunningHot()
Determine if the HMR server is running.
string toHtml()
Get the Vite tag content as a string of HTML.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/10.x/Illuminate/Foundation/Vite.html