Include base in hotFile without modifying server.origin replacement #296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Unfortunately #290 - while fixing the
hotFile
problem - broke the transform function's origin replacement when using a base in the configuration resulting in broken asset URLs.Vite generates URLs using the
origin
and thebase
. As this plugin now replaces theorigin
(__laravel_vite_placeholder__
) by default with theorigin+base
, the base is included twice in the asset URLs, which results in the given assets not loading.On the other hand, the original problem that #290 solved was real as well, as Laravel did not take the
base
into account before this PR and the main files did not load when settingbase
in the configuration. This means that thebase
has to be included in thehotFile
. It should also be included when setting theorigin
explicitly, which is a special case that #290 did not handle.This pull request includes the
base
in thehotFile
, but leaves the origin (or more precisely the replacement) as is. This should both solve the original problem and avoid including thebase
in the asset URLs twice.public/hot
contenthttps://test.localhost:443/vite-test-base
https://test.localhost:443/vite-test-base
https://test.localhost/vite-test-base/vite-test-base/resources/images/test.svg
https://test.localhost/vite-test-base/resources/images/test.svg
https://test.localhost/vite-test-base/node_modules/.vite/deps/chunk-NDQ3I6BD.js?v=df756ebe
https://test.localhost/vite-test-base/node_modules/.vite/deps/chunk-NDQ3I6BD.js?v=df756ebe
This change should not be a breaking change as it is a fix to something that changed in vite 5 compared to vite 4 as mentioned here.