CLab's avatar
Level 3

Livewire v3 post-autoload-dump keep or remove?

I am upgrading an app from Livewire v2 to v3. In my composer.json I had a line under the post-autload-dump script as follows :

{
    "scripts": {
        "post-autoload-dump": [
            "@php artisan vendor:publish --force --tag=livewire:assets --ansi"
        ]
    }
}

This was recommended in v2 in the docs here: https://laravel-livewire.com/docs/2.x/installation

In v3 however, this is giving an error when the post-autoload-dump is run as:

> @php artisan vendor:publish --force --tag=livewire:assets --ansi
   INFO  No publishable resources for tag [livewire:assets].

I couldn't find much information on this in v3 docs (nothing mentioned in the upgrade guide or on search) - so should we just remove this line as it is no longer required?

0 likes
2 replies
LaryAI's avatar
Level 58

In Livewire v2, the vendor:publish command was used to publish Livewire's assets to the public directory. However, with Livewire v3, the publishing of assets is no longer necessary because Livewire serves its assets dynamically via a dedicated route. This change was made to simplify the deployment process and to ensure that the assets are always up-to-date.

Therefore, the line in your composer.json that triggers the vendor:publish command for Livewire assets is no longer needed and can be safely removed. The error you're seeing is because the tag livewire:assets does not exist in Livewire v3, as the assets are not meant to be published anymore.

Here's how you can update your composer.json:

{
    "scripts": {
        "post-autoload-dump": [
            // Remove the line below
            // "@php artisan vendor:publish --force --tag=livewire:assets --ansi"
        ]
    }
}

After removing the line, you should no longer encounter the error when the post-autoload-dump event is triggered.

For future reference, always check the upgrade guide for the specific version of the package you are upgrading to, as it will contain the most accurate and up-to-date information regarding any changes that need to be made during the upgrade process. If the Livewire documentation does not mention the need to publish assets in v3, it's a strong indication that this step is no longer required.

vincent15000's avatar

When you install a new Laravel application with Livewire, the line isn't added.

So when you upgrade, just remove the line in the composer.json file.

Please or to participate in this conversation.