diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php index 6c517d336ebf..f870ef8dc1fa 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php @@ -115,7 +115,7 @@ protected function withoutVite() $this->swap(Vite::class, new class extends Vite { - public function __invoke($entrypoints, $buildDirectory = null) + public function __invoke($entrypoints, $buildDirectory = null, $assetsUrl = null) { return new HtmlString(''); } diff --git a/src/Illuminate/Foundation/Vite.php b/src/Illuminate/Foundation/Vite.php index 9c0a24d04f98..50f4c5af070d 100644 --- a/src/Illuminate/Foundation/Vite.php +++ b/src/Illuminate/Foundation/Vite.php @@ -90,6 +90,13 @@ class Vite implements Htmlable */ protected static $manifests = []; + /** + * The custom assets url + * + * @var string|null + */ + protected $assetsUrl = null; + /** * Get the preloaded assets. * @@ -256,10 +263,11 @@ public function usePreloadTagAttributes($attributes) * * @throws \Exception */ - public function __invoke($entrypoints, $buildDirectory = null) + public function __invoke($entrypoints, $buildDirectory = null, $assetsUrl = null) { $entrypoints = collect($entrypoints); $buildDirectory ??= $this->buildDirectory; + $this->assetsUrl =$assetsUrl; if ($this->isRunningHot()) { return new HtmlString( @@ -688,6 +696,10 @@ public function content($asset, $buildDirectory = null) */ protected function assetPath($path, $secure = null) { + if (isset($this->assetsUrl)) { + return Str::finish($this->assetsUrl, '/') . $path; + } + return asset($path, $secure); }