From 9483e194453c81d6822b9624c45407d64b5489ab Mon Sep 17 00:00:00 2001 From: Roman Chernyshov Date: Fri, 13 Dec 2024 17:38:29 +0300 Subject: [PATCH] Make possibility pass build directory --- modules/cms/twig/Extension.php | 4 ++-- modules/system/classes/asset/Vite.php | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/cms/twig/Extension.php b/modules/cms/twig/Extension.php index 01ed17438e..4e410d3b2d 100644 --- a/modules/cms/twig/Extension.php +++ b/modules/cms/twig/Extension.php @@ -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); } /** diff --git a/modules/system/classes/asset/Vite.php b/modules/system/classes/asset/Vite.php index f5dabc7057..f2a74f986e 100644 --- a/modules/system/classes/asset/Vite.php +++ b/modules/system/classes/asset/Vite.php @@ -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'); @@ -32,7 +34,7 @@ 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')); } /** @@ -40,11 +42,12 @@ public function __invoke($entrypoints, $package = null) * * @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); } }