Skip to content

ModularousVite ​

Facade: Unusualify\Modularous\Facades\ModularousVite
Accessor: Unusualify\Modularous\Support\ModularousVite::class
Underlying: Unusualify\Modularous\Support\ModularousVite

Modularous's Vite integration layer. Works like Laravel's built-in Vite facade but resolves assets from the Modularous package's build directory rather than the host application's public/build.

Methods ​

MethodSignatureDescription
__invoke(string|string[] $entrypoints, string|null $buildDirectory = null): HtmlStringGenerates <script> and <link> tags for entrypoints
hotAsset(string $asset): stringReturns the HMR dev server URL for an asset
isRunningHot(): boolReturns true if Vite dev server is active
makeTagForChunk(string $src, string $url, array|null $chunk, array|null $manifest): stringGenerates an HTML tag for a manifest chunk
makePreloadTagForChunk(string $src, string $url, array $chunk, array $manifest): stringGenerates a <link rel="modulepreload"> tag
chunk(array $manifest, string $file): arrayReturns the manifest entry for a file
manifest(string $buildDirectory): arrayReturns the parsed Vite manifest JSON
assetPath(string $path): stringReturns the public path for a built asset
isCssPath(string $path): boolReturns true if the path points to a CSS file

Usage ​

In Blade layouts:

php
{!! ModularousVite::__invoke(['resources/js/app.js', 'resources/css/app.css']) !!}

Or via the @modularousVite Blade directive registered by the package:

blade
@modularousVite(['resources/js/app.js'])

Notes ​

  • During development (isRunningHot() === true) assets are served from the Vite HMR server.
  • In production, the manifest is read from the Modularous package's public/build/manifest.json.