From e3ad070dd0cb05c7fd51ed062b182f7e38b024ef Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Wed, 25 Jan 2023 16:03:39 -0500 Subject: [PATCH] refactor: Updated the `craft.vite.asset()` function to work with Vite 3.x or later, where assets are stored as top-level entries in the `manifest.json` ([#56](https://github.com/nystudio107/craft-vite/issues/56)) ([#31](https://github.com/nystudio107/craft-vite/issues/31)) --- src/services/ViteService.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/services/ViteService.php b/src/services/ViteService.php index 35c854d..ad85f0a 100755 --- a/src/services/ViteService.php +++ b/src/services/ViteService.php @@ -366,7 +366,11 @@ public function manifestAsset(string $path): string } } - return ''; + // With Vite 3.x or later, the assets are also included as top-level entries in the + // manifest, so check there, too + $entry = ManifestHelper::extractEntry($path); + + return $entry === '' ? '' : FileHelper::createUrl($this->serverPublic, $entry); } /**