You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Laravel package that uses Vite to build assets. Those assets must be published using vendor:publish when installing the package in a project. This works correctly if it is the first time you do that as there are no files yet in the destination folder.
The problem occurs when you publish the assets again after an update of the Laravel package. Then the new asset files are correctly added to the destination folder, but the old asset files are not deleted. That's because each asset filename contains an id unique for that vite build.
Currently the vendor:publish command just overrides existing files, which works when using Laravel Mix to build your assets, as those asset filenames don't contain a unique build id. But this does work when the assets are build using Vite.
Steps To Reproduce
Install Telescope in Laravel project (specifically version v4.17.0 as that one uses Vite). I use that specific Telescope version as an example as I don't really know any other public composer packages that use Vite to build assets.
Run php artisan telescope:publish. You will see assets in your public folder
Change the unique file suffixes of those assets
Run php artisan telescope:publish again. You will see that new files are added but the old files (the ones you renamed) are still there.
The text was updated successfully, but these errors were encountered:
We have reverted the use of Vite with Telescope. I've made a note that if we revisit using Vite there we will need to consider this issue.
I recommend updating to the latest telescope and manually clearing the old files.
I've also made a note that we could add a --clean flag to the publish command so that you have control of this in userland as well, where providing this flag would remove any existing files before writing the new files.
Laravel Version
10.31.0
PHP Version
8.2
Database Driver & Version
No response
Description
I have a Laravel package that uses Vite to build assets. Those assets must be published using
vendor:publish
when installing the package in a project. This works correctly if it is the first time you do that as there are no files yet in the destination folder.The problem occurs when you publish the assets again after an update of the Laravel package. Then the new asset files are correctly added to the destination folder, but the old asset files are not deleted. That's because each asset filename contains an id unique for that vite build.
Currently the
vendor:publish
command just overrides existing files, which works when using Laravel Mix to build your assets, as those asset filenames don't contain a unique build id. But this does work when the assets are build using Vite.Steps To Reproduce
Install Telescope in Laravel project (specifically version v4.17.0 as that one uses Vite). I use that specific Telescope version as an example as I don't really know any other public composer packages that use Vite to build assets.
Run
php artisan telescope:publish
. You will see assets in your public folderChange the unique file suffixes of those assets
Run
php artisan telescope:publish
again. You will see that new files are added but the old files (the ones you renamed) are still there.The text was updated successfully, but these errors were encountered: