Skip to content

Commit 2139f0e

Browse files
Support customizing the Vite build directory (#1272)
1 parent 154a8c8 commit 2139f0e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

modules/cms/twig/Extension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ public function themeFilter($url): string
171171
/**
172172
* Generates Vite tags via Laravel's Vite Object.
173173
*/
174-
public function viteFunction(array $entrypoints, string $package): \Illuminate\Support\HtmlString
174+
public function viteFunction(array $entrypoints, string $package, ?string $buildDirectory = null): \Illuminate\Support\HtmlString
175175
{
176-
return Vite::tags($entrypoints, $package);
176+
return Vite::tags($entrypoints, $package, $buildDirectory);
177177
}
178178

179179
/**

modules/system/classes/asset/Vite.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ class Vite extends LaravelVite
1414
*
1515
* @param string|array $entrypoints The list of entry points for Vite
1616
* @param string|null $package The package name of the plugin or theme
17+
* @param string|null $buildDirectory The Vite build directory
18+
*
1719
* @return HtmlString
1820
*
1921
* @throws SystemException
2022
*/
21-
public function __invoke($entrypoints, $package = null)
23+
public function __invoke($entrypoints, $package = null, $buildDirectory = null)
2224
{
2325
if (!$package) {
2426
throw new \InvalidArgumentException('A package must be passed');
@@ -32,19 +34,20 @@ public function __invoke($entrypoints, $package = null)
3234
}
3335

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

3840
/**
3941
* Helper method to generate Vite tags for an entrypoint(s).
4042
*
4143
* @param string|array $entrypoints The list of entry points for Vite
4244
* @param string $package The package name of the plugin or theme
45+
* @param string|null $buildDirectory The Vite build directory
4346
*
4447
* @throws SystemException
4548
*/
46-
public static function tags(array|string $entrypoints, string $package): HtmlString
49+
public static function tags(array|string $entrypoints, string $package, ?string $buildDirectory = null): HtmlString
4750
{
48-
return App::make(\Illuminate\Foundation\Vite::class)($entrypoints, $package);
51+
return App::make(\Illuminate\Foundation\Vite::class)($entrypoints, $package, $buildDirectory);
4952
}
5053
}

0 commit comments

Comments
 (0)