Skip to content

[12.x] Make Vite asset path generation extendable via inheritance#57292

Merged
taylorotwell merged 1 commit into
laravel:12.xfrom
daun:feat/vite-public-path-method
Oct 7, 2025
Merged

[12.x] Make Vite asset path generation extendable via inheritance#57292
taylorotwell merged 1 commit into
laravel:12.xfrom
daun:feat/vite-public-path-method

Conversation

@daun

@daun daun commented Oct 7, 2025

Copy link
Copy Markdown
Contributor

A much trimmed-down version of the proposed change in #57289 which was (rightly) rejected as feature creep.

This adds nothing but only makes the Vite class more extendable via inheritance. It moves the public path generation of Vite assets into a protected method. Any custom setups can extend the Vite class and overwrite this method.

Example usage (remove query string hash before generating disk path):

->withSingletons([
    Vite::class => fn() => new class extends Vite {
        protected function publicPath($path) {
            return parent::publicPath(Str::before($path, '?'));
        }
    }
])

@taylorotwell taylorotwell merged commit 1c669e6 into laravel:12.x Oct 7, 2025
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants