Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gdebrauwer opened this issue Nov 10, 2023 · 1 comment
Assignees

Comments

@gdebrauwer
Copy link
Contributor

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.

@timacdonald
Copy link
Member

Hey @gdebrauwer,

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants