Skip to content

Commit

Permalink
Make possibility pass build directory
Browse files Browse the repository at this point in the history
  • Loading branch information
truechernyshov committed Dec 13, 2024
1 parent a7f9ce5 commit 9483e19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions modules/cms/twig/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ public function themeFilter($url): string
/**
* Generates Vite tags via Laravel's Vite Object.
*/
public function viteFunction(array $entrypoints, string $package): \Illuminate\Support\HtmlString
public function viteFunction(array $entrypoints, string $package, ?string $buildDirectory = null): \Illuminate\Support\HtmlString
{
return Vite::tags($entrypoints, $package);
return Vite::tags($entrypoints, $package, $buildDirectory);
}

/**
Expand Down
11 changes: 7 additions & 4 deletions modules/system/classes/asset/Vite.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class Vite extends LaravelVite
*
* @param string|array $entrypoints The list of entry points for Vite
* @param string|null $package The package name of the plugin or theme
* @param string|null $buildDirectory The Vite build directory
*
* @return HtmlString
*
* @throws SystemException
*/
public function __invoke($entrypoints, $package = null)
public function __invoke($entrypoints, $package = null, $buildDirectory = null)
{
if (!$package) {
throw new \InvalidArgumentException('A package must be passed');
Expand All @@ -32,19 +34,20 @@ public function __invoke($entrypoints, $package = null)
}

$this->useHotFile(base_path($compilableAssetPackage['path'] . '/assets/dist/hot'));
return parent::__invoke($entrypoints, $compilableAssetPackage['path'] . '/assets/dist');
return parent::__invoke($entrypoints, $compilableAssetPackage['path'] . ($buildDirectory ?? '/assets/dist'));
}

/**
* Helper method to generate Vite tags for an entrypoint(s).
*
* @param string|array $entrypoints The list of entry points for Vite
* @param string $package The package name of the plugin or theme
* @param string|null $buildDirectory The Vite build directory
*
* @throws SystemException
*/
public static function tags(array|string $entrypoints, string $package): HtmlString
public static function tags(array|string $entrypoints, string $package, ?string $buildDirectory = null): HtmlString
{
return App::make(\Illuminate\Foundation\Vite::class)($entrypoints, $package);
return App::make(\Illuminate\Foundation\Vite::class)($entrypoints, $package, $buildDirectory);
}
}

0 comments on commit 9483e19

Please sign in to comment.