Contents

System\Classes\Vite

Overview

Vite renders the tags for Vite entry points built inside a directory on disk, such as a theme or a plugin. Laravel's Vite reads the manifest and hot file from public_path(), which only holds them when the directory is mirrored into the public folder, so it fails for a project that commits a public folder and runs from the project root.

(new Vite)
    ->useBasePath(themes_path('demo'))
    ->useBuildDirectory('assets/dist')
    ->createAssetPathsUsing(fn ($path) => url('themes/demo/'.$path))
    ->withEntryPoints(['assets/css/theme.css', 'assets/js/app.js'])
    ->toHtml();

Without a base path it behaves like Laravel's Vite.

Extends
  • Illuminate\Foundation\Vite
Implements
  • Illuminate\Contracts\Support\Htmlable

Protected Properties

protected string|null $basePath

basePath is the directory the build directory and hot file are in

Show inherited protected properties

Inherited Protected Properties

  • $nonce - The Content Security Policy nonce to apply to all generated tags. (defined in Illuminate\Foundation\Vite)
  • $integrityKey - The key to check for integrity hashes within the manifest. (defined in Illuminate\Foundation\Vite)
  • $entryPoints - The configured entry points. (defined in Illuminate\Foundation\Vite)
  • $hotFile - The path to the "hot" file. (defined in Illuminate\Foundation\Vite)
  • $buildDirectory - The path to the build directory. (defined in Illuminate\Foundation\Vite)
  • $manifestFilename - The name of the manifest file. (defined in Illuminate\Foundation\Vite)
  • $assetPathResolver - The custom asset path resolver. (defined in Illuminate\Foundation\Vite)
  • $scriptTagAttributesResolvers - The script tag attributes resolvers. (defined in Illuminate\Foundation\Vite)
  • $styleTagAttributesResolvers - The style tag attributes resolvers. (defined in Illuminate\Foundation\Vite)
  • $preloadTagAttributesResolvers - The preload tag attributes resolvers. (defined in Illuminate\Foundation\Vite)
  • $preloadedAssets - The preloaded assets. (defined in Illuminate\Foundation\Vite)
  • $manifests - The cached manifest files. (defined in Illuminate\Foundation\Vite)
  • $fonts - The ViteFonts instance. (defined in Illuminate\Foundation\Vite)
  • $fontsManifestFilename - The name of the font manifest file. (defined in Illuminate\Foundation\Vite)
  • $prefetchStrategy - The prefetching strategy to use. (defined in Illuminate\Foundation\Vite)
  • $prefetchConcurrently - The number of assets to load concurrently when using the "waterfall" strategy. (defined in Illuminate\Foundation\Vite)
  • $prefetchEvent - The name of the event that should trigger prefetching. The event must be dispatched on the window. (defined in Illuminate\Foundation\Vite)
  • $macros - The registered string macros. (defined in Illuminate\Foundation\Vite)

Public Methods

public hotFile()

public hotFile(): string 

hotFile returns the path to the hot file, which the dev server writes to the base path.

public useBasePath()

public useBasePath($path): static 

useBasePath sets the directory the build directory and hot file are relative to.

Show inherited public methods

Inherited Public Methods

  • __call() - Dynamically handle calls to the class. (defined in Illuminate\Foundation\Vite)
  • __callStatic() - Dynamically handle calls to the class. (defined in Illuminate\Foundation\Vite)
  • __invoke() - Generate Vite tags for an entrypoint. (defined in Illuminate\Foundation\Vite)
  • asset() - Get the URL for an asset. (defined in Illuminate\Foundation\Vite)
  • content() - Get the content of a given asset. (defined in Illuminate\Foundation\Vite)
  • createAssetPathsUsing() - Resolve asset paths using the provided resolver. (defined in Illuminate\Foundation\Vite)
  • cspNonce() - Get the Content Security Policy nonce applied to all generated tags. (defined in Illuminate\Foundation\Vite)
  • devServerUrl() - Get the URL of the running Vite development server. (defined in Illuminate\Foundation\Vite)
  • flush() - Flush state. (defined in Illuminate\Foundation\Vite)
  • flushMacros() - Flush the existing macros. (defined in Illuminate\Foundation\Vite)
  • fonts() - Render font preload links and inline styles. (defined in Illuminate\Foundation\Vite)
  • hasMacro() - Checks if macro is registered. (defined in Illuminate\Foundation\Vite)
  • isRunningHot() - Determine if the HMR server is running. (defined in Illuminate\Foundation\Vite)
  • macro() - Register a custom macro. (defined in Illuminate\Foundation\Vite)
  • manifestHash() - Get a unique hash representing the current manifest, or null if there is no manifest. (defined in Illuminate\Foundation\Vite)
  • mergeEntryPoints() - Merge additional Vite entry points with the current set. (defined in Illuminate\Foundation\Vite)
  • mixin() - Mix another object into the class. (defined in Illuminate\Foundation\Vite)
  • prefetch() - Eagerly prefetch assets. (defined in Illuminate\Foundation\Vite)
  • preloadedAssets() - Get the preloaded assets. (defined in Illuminate\Foundation\Vite)
  • reactRefresh() - Generate React refresh runtime script. (defined in Illuminate\Foundation\Vite)
  • toHtml() - Get the Vite tag content as a string of HTML. (defined in Illuminate\Foundation\Vite)
  • useAggressivePrefetching() - Use the "aggressive" prefetching strategy. (defined in Illuminate\Foundation\Vite)
  • useBuildDirectory() - Set the Vite build directory. (defined in Illuminate\Foundation\Vite)
  • useCspNonce() - Generate or set a Content Security Policy nonce to apply to all generated tags. (defined in Illuminate\Foundation\Vite)
  • useFontsManifestFilename() - Set the font manifest filename. (defined in Illuminate\Foundation\Vite)
  • useHotFile() - Set the Vite "hot" file path. (defined in Illuminate\Foundation\Vite)
  • useIntegrityKey() - Use the given key to detect integrity hashes in the manifest. (defined in Illuminate\Foundation\Vite)
  • useManifestFilename() - Set the filename for the manifest file. (defined in Illuminate\Foundation\Vite)
  • usePrefetchStrategy() - Set the prefetching strategy. (defined in Illuminate\Foundation\Vite)
  • usePreloadTagAttributes() - Use the given callback to resolve attributes for preload tags. (defined in Illuminate\Foundation\Vite)
  • useScriptTagAttributes() - Use the given callback to resolve attributes for script tags. (defined in Illuminate\Foundation\Vite)
  • useStyleTagAttributes() - Use the given callback to resolve attributes for style tags. (defined in Illuminate\Foundation\Vite)
  • useWaterfallPrefetching() - Use the "waterfall" prefetching strategy. (defined in Illuminate\Foundation\Vite)
  • withEntryPoints() - Set the Vite entry points. (defined in Illuminate\Foundation\Vite)

Protected Methods

protected manifestPath()

protected manifestPath($buildDirectory): string 

manifestPath returns the path to the manifest file in the build directory.

protected publicPath()

protected publicPath($path): string 

publicPath returns the path to a built file, used to read its content.

Show inherited protected methods

Inherited Protected Methods

  • assetPath() - Generate an asset path for the application. (defined in Illuminate\Foundation\Vite)
  • chunk() - Get the chunk for the given entry point / asset. (defined in Illuminate\Foundation\Vite)
  • hotAsset() - Get the path to a given asset when running in HMR mode. (defined in Illuminate\Foundation\Vite)
  • isCssPath() - Determine whether the given path is a CSS file. (defined in Illuminate\Foundation\Vite)
  • makePreloadTagForChunk() - Make a preload tag for the given chunk. (defined in Illuminate\Foundation\Vite)
  • makeScriptTag() - Generate a script tag for the given URL. (defined in Illuminate\Foundation\Vite)
  • makeScriptTagWithAttributes() - Generate a script tag with attributes for the given URL. (defined in Illuminate\Foundation\Vite)
  • makeStylesheetTag() - Generate a stylesheet tag for the given URL in HMR mode. (defined in Illuminate\Foundation\Vite)
  • makeStylesheetTagWithAttributes() - Generate a link tag with attributes for the given URL. (defined in Illuminate\Foundation\Vite)
  • makeTag() - Generate an appropriate tag for the given URL in HMR mode. (defined in Illuminate\Foundation\Vite)
  • makeTagForChunk() - Make tag for the given chunk. (defined in Illuminate\Foundation\Vite)
  • manifest() - Get the manifest file for the given build directory. (defined in Illuminate\Foundation\Vite)
  • nonceAttribute() - Get the nonce attribute for the prefetch script tags. (defined in Illuminate\Foundation\Vite)
  • parseAttributes() - Parse the attributes into key="value" strings. (defined in Illuminate\Foundation\Vite)
  • renderFontPreloads() - Render preload link tags for font entries. (defined in Illuminate\Foundation\Vite)
  • renderFontStyle() - Render the inline style block for the font manifest. (defined in Illuminate\Foundation\Vite)
  • resolveFontPreloadAttributes() - Resolve the attributes for a font preload tag. (defined in Illuminate\Foundation\Vite)
  • resolveImports() - Recursively resolve all imports for the given chunk. (defined in Illuminate\Foundation\Vite)
  • resolvePreloadTagAttributes() - Resolve the attributes for the chunks generated preload tag. (defined in Illuminate\Foundation\Vite)
  • resolveScriptTagAttributes() - Resolve the attributes for the chunks generated script tag. (defined in Illuminate\Foundation\Vite)
  • resolveStylesheetTagAttributes() - Resolve the attributes for the chunks generated stylesheet tag. (defined in Illuminate\Foundation\Vite)
  • viteFonts() - Get the ViteFonts instance. (defined in Illuminate\Foundation\Vite)