Skip to content

Publish of vite files using "vendor:publish" command does not cleanup old vite files #48964

Closed
@gdebrauwer

Description

@gdebrauwer

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

  1. 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.

  2. Run php artisan telescope:publish. You will see assets in your public folder

  3. Change the unique file suffixes of those assets

  4. 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions