fix: scripts and styles were missing from built HTML on Windows #16421
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.
Description
Fix HTML entry file generation under Windows where different path
separation characters exists than on POSIX filesystems. This fixes issue
#15992.
The bug was not present in Vite 5.0.12, but still exists in 5.2.8.
I've traced it down to a bug in Vite which is related to path
handling and manifests itself only under Windows filesystems. The
chunk.facadeModuleId
is something likeC:\Users\rse\xxx\index.html
(the Windows path separation characters are in place) and the
id
isC:/Users/rse/xxx/index.html
(where POSIX path separation charactersare in place). As a result, the chunk is not found and hence the
tags not emitted during the HTML generation.
The workaround by using
path.resolve()
on thebuild.rollupOptions.input
works, but it would be better if thecomparison inside Vite is fixed. This is what this PR attempts to do.