Skip to content

Commit

Permalink
Merge pull request #9 from samuelbirch/develop-v4
Browse files Browse the repository at this point in the history
public assets v4
  • Loading branch information
khalwat committed Jun 29, 2022
2 parents 954c37a + 9a8bffc commit 3d6bec1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
19 changes: 18 additions & 1 deletion src/services/ViteService.php
Expand Up @@ -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);
}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/variables/ViteVariableTrait.php
Expand Up @@ -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)
);
}

Expand Down

0 comments on commit 3d6bec1

Please sign in to comment.