Issue with loading assets with @assets #8769
Replies: 4 comments 1 reply
-
|
I thought I was going insane, but I'm running into this too. I load in two scripts and a stylesheet (using Vite) for one component which is lazy loaded. In dev as you say, this works perfectly, but in production it breaks as it only ends up preloading the assets and never actually applying the stylesheet itself. |
Beta Was this translation helpful? Give feedback.
-
|
To expand the context:
|
Beta Was this translation helpful? Give feedback.
-
|
Same pain felt here on this one. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I created a pull request that addresses this issue: #9150 In the meantime, as you noted, you should avoid, when possible, to put link tags before script tags; if not possible, you can place assets in the page instead of loading them dynamically in a component as a workaround (this behavior only happens when assets are loaded dynamically) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Livewire version
v3.5.6
Laravel version
v11
Which PHP version are you using?
PHP 8.3
Steps To Reproduce
Hey folks, there's a bug with loading assets when the asset is not <script>.
I've made a tiny demo on Wirebox.
If we take an example from the docs and swap the order - load CSS first then JS, it fails to load JS.
From my research, this only happens when we dynamically swap components on the page and not in SPA mode with wire:navigate.
The problem wouldn't be so big if this was noted somewhere, however, the issue is also that when you run the Laravel app in development mode with Vite, the
@vitetag produces only one script file, while the production build makes two lines - preload link and JS file, which means assets don't load in production (if there's external import, since that creates link with preload).I've dig deeper and it looks like the script hangs out here.
which means the promise never resolves resulting rest of the assets never loading.
Repository or Wirebox URL
https://wirebox.app/b/4np0r
Additional information
No response
Please confirm (incomplete submissions will not be addressed)
Beta Was this translation helpful? Give feedback.
All reactions