@@ -49,15 +49,15 @@ class Theme
4949 /**
5050 * The Parent theme.
5151 */
52- protected string | Theme | null $ parent ;
52+ protected string | Theme | null $ parent ;
5353
5454 /**
5555 * The theme statud (enabled or not).
5656 */
5757 protected bool $ enabled = false ;
5858
5959 /**
60- * Theme extra data.
60+ * Theme extra data
6161 */
6262 protected array $ extra = [];
6363
@@ -102,7 +102,7 @@ public function getAssetsPath(string $path = null): string
102102 /**
103103 * Get theme views paths.
104104 * Build Paths array.
105- * All paths are relative to Config::get('themes-manager.directory').
105+ * All paths are relative to Config::get('themes-manager.directory')
106106 */
107107 public function getViewPaths (string $ path = '' ): array
108108 {
@@ -121,7 +121,7 @@ public function getViewPaths(string $path = ''): array
121121 }
122122
123123 /**
124- * Set extra data.
124+ * Set extra data
125125 */
126126 public function setExtra (array $ extra ): self
127127 {
@@ -131,7 +131,7 @@ public function setExtra(array $extra): self
131131 }
132132
133133 /**
134- * Set theme version.
134+ * Set theme version
135135 */
136136 public function setVersion (string $ version ): self
137137 {
@@ -141,7 +141,7 @@ public function setVersion(string $version): self
141141 }
142142
143143 /**
144- * Set theme description.
144+ * Set theme description
145145 */
146146 public function setDescription (string $ description ): self
147147 {
@@ -151,7 +151,7 @@ public function setDescription(string $description): self
151151 }
152152
153153 /**
154- * Set theme name.
154+ * Set theme name
155155 */
156156 public function setName (string $ name ): self
157157 {
@@ -180,7 +180,7 @@ public function setPath(string $path): self
180180 }
181181
182182 /**
183- * Set theme vendor.
183+ * Set theme vendor
184184 */
185185 public function setVendor (string $ vendor = null ): self
186186 {
@@ -204,7 +204,7 @@ public function hasParent(): bool
204204 /**
205205 * Set parent Theme.
206206 */
207- public function setParent (string | Theme | null $ theme ): self
207+ public function setParent (string | Theme | null $ theme ): self
208208 {
209209 $ this ->parent = empty ($ theme ) ? null : $ theme ;
210210
@@ -214,7 +214,7 @@ public function setParent(string | Theme | null $theme): self
214214 /**
215215 * Get parent Theme.
216216 */
217- public function getParent (): Theme | null
217+ public function getParent (): Theme | null
218218 {
219219 if (is_string ($ this ->parent ) && !empty ($ this ->parent )) {
220220 $ this ->parent = ThemesManager::findByName ($ this ->parent );
@@ -305,11 +305,25 @@ public function url(string $url, bool $absolute = true): string
305305 $ url = str_replace ($ matches , $ this ->extra , $ url );
306306 }
307307
308+ // Check into Vite manifest file
309+ $ manifesPath = $ this ->getAssetsPath ('manifest.json ' );
310+ if (file_exists ($ manifesPath )) {
311+ $ manifest = file_get_contents ($ manifesPath );
312+ $ manifest = json_decode ($ manifest , true );
313+
314+ if (array_key_exists ($ url , $ manifest )) {
315+ // Lookup asset in current's theme assets path
316+ $ fullUrl = $ this ->getAssetsPath ($ manifest [$ url ]['file ' ]);
317+
318+ return ($ absolute ? asset ($ fullUrl ) : $ fullUrl );
319+ }
320+ }
321+
308322 // Lookup asset in current's theme assets path
309323 $ fullUrl = $ this ->getAssetsPath ($ url );
310324
311325 if (file_exists (public_path ($ fullUrl ))) {
312- return $ absolute ? asset ($ fullUrl ) : $ fullUrl ;
326+ return ( $ absolute ? asset ($ fullUrl ) : $ fullUrl) ;
313327 }
314328
315329 // If not found then lookup in parent's theme assets path
@@ -319,7 +333,7 @@ public function url(string $url, bool $absolute = true): string
319333
320334 // No parent theme? Lookup in the public folder.
321335 if (file_exists (public_path ($ url ))) {
322- return $ absolute ? asset ('' ) . $ url : $ url ;
336+ return ( $ absolute ? asset ('' ) . $ url : $ url) ;
323337 }
324338
325339 Log::warning ("Asset [ {$ url }] not found for Theme [ {$ this ->name }] " );
0 commit comments