vincent15000's avatar

How to force update Livewire assets while upgrading from version 2 to 3 ?

Hello,

I just had a dysfunction while upgrading from Livewire 2 to 3.

I have published the assets and now it works fine.

But when installing a new Livewire 3 application, the assets are not published and it works fine.

So there is probably another way than publishing the assets ?

What do you suggest me ?

Thanks a lot ;).

V

0 likes
2 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

Certainly! Here’s a clear solution addressing the question about updating Livewire 3’s assets when upgrading from v2, and best practices regarding publishing assets.


When upgrading from Livewire 2 to 3, it's important to note that you no longer need to publish Livewire's assets. In Livewire 3, assets (JavaScript/CSS) are loaded via CDN by default, which makes asset management simpler and eliminates caching issues usually caused by locally published assets.

Why not publish?

  • Livewire 3 automatically injects its scripts into your Blade layout using:
    @livewireScripts
    @livewireStyles
    
  • The CDN-based approach ensures you always have the latest version, unless you intentionally want to customize the assets.

If you previously published assets (using php artisan livewire:publish):

This can cause issues as Laravel will use your local (and possibly outdated) copies. To revert to using CDN assets:

  1. Delete Your Published Assets

    Published Livewire assets are typically located in the public/vendor/livewire directory.
    Delete this folder:

    rm -rf public/vendor/livewire
    
  2. Remove Published Asset References from webpack.mix.js, vite.config.js, etc.
    Ensure you don't manually copy or reference outdated assets in your build process.

  3. Clear Your Caches
    Not strictly necessary, but it can help:

    php artisan view:clear
    php artisan cache:clear
    

Summary

  • New Livewire 3 installs: No asset publishing required.
  • Upgraded projects: Delete any published Livewire assets so CDN is used.
  • Only publish assets (php artisan livewire:publish) if you need to customize them (rarely needed with v3).

Blade Layout Example (recommended way):

<!DOCTYPE html>
<html>
<head>
    @livewireStyles
</head>
<body>
    @yield('content')

    @livewireScripts
</body>
</html>

References:

Let me know if you have any follow-up questions!

1 like
vincent15000's avatar

Ok ... effectively the Livewire were already published with Livewire 2, I just had to delete them from the public directory to have it working with Livewire 3.

Please or to participate in this conversation.