Skip to content

Conversation

daun
Copy link
Contributor

@daun daun commented Oct 7, 2025

Current state

  • Vite::content(), introduced in 10.x, allows inlining raw contents of Vite assets
  • The disk paths for reading the contents are hardcoded to use public_path
  • This currently does not support some custom setups like e.g. hashes in query strings

Proposed change

  • Add a customizable resolver for asset disk paths
  • API: $vite->createPublicPathsUsing(fn ($path) => $path)
  • Mirrors $vite->createAssetPathsUsing() for a consistent API: one for URLs, one for disk paths

Example use case

  • Move asset hash into query string using vite-plugin-query-string-versioning
    • Default manifest file property: assets/font.356cadeb.woff
    • With plugin: assets/font.woff?v=356cadeb
  • The plugin cannot rewrite the manifest’s file key as it is used to construct both the URL and the disk path
  • Allowing a custom resolver lets users strip query strings or otherwise transform the path before disk access
$vite->createPublicPathsUsing(
  fn ($path) => public_path(Str::before($path, '?'))
};

Backward compatibility

  • No breaking changes
  • If no resolver is registered, current behavior remains: paths are resolved via public_path

Tests

  • Added tests for adding and removing custom resolver
  • Added a param to two test helpers for creating test assets

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

@daun
Copy link
Contributor Author

daun commented Oct 7, 2025

Makes sense, thanks for looking it over :)

I've submitted an alternate PR for making things more extendable so these features can be implemented in userland.

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