diff --git a/src/services/ViteService.php b/src/services/ViteService.php index 1a771c9..124da39 100755 --- a/src/services/ViteService.php +++ b/src/services/ViteService.php @@ -301,11 +301,15 @@ public function entry(string $path): string * * @return string */ - public function asset(string $path): string + public function asset(string $path, bool $public=false): string { if ($this->devServerRunning()) { return $this->devServerAsset($path); } + + if ($public) { + return $this->publicAsset($path); + } return $this->manifestAsset($path); } @@ -322,6 +326,19 @@ public function devServerAsset(string $path): string // Return a URL to the given asset return FileHelper::createUrl($this->devServerPublic, $path); } + + /** + * Return the URL for the asset from the public Vite folder + * + * @param string $path + * + * @return string + */ + public function publicAsset(string $path): string + { + // Return a URL to the given asset + return FileHelper::createUrl($this->serverPublic, $path); + } /** * Return the URL for the asset from the manifest.json file diff --git a/src/variables/ViteVariableTrait.php b/src/variables/ViteVariableTrait.php index dd4037d..00a06ae 100755 --- a/src/variables/ViteVariableTrait.php +++ b/src/variables/ViteVariableTrait.php @@ -91,10 +91,10 @@ public function entry(string $path): Markup * * @return Markup */ - public function asset(string $path): Markup + public function asset(string $path, bool $public=false): Markup { return Template::raw( - $this->viteService->asset($path) + $this->viteService->asset($path, $public) ); }