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 the base. As this plugin now replaces the origin (__laravel_vite_placeholder__) by default with the origin+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 setting base in the configuration. This means that the base has to be included in the hotFile. It should also be included when setting the origin explicitly, which is a special case that #290 did not handle.
This pull request includes the base in the hotFile, but leaves the origin (or more precisely the replacement) as is. This should both solve the original problem and avoid including the base in the asset URLs twice.
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.