feat: generate default index.html into frontend/generated/#24469
Draft
Artur- wants to merge 3 commits into
Draft
feat: generate default index.html into frontend/generated/#24469Artur- wants to merge 3 commits into
Artur- wants to merge 3 commits into
Conversation
Hide the Vaadin-generated index.html from source control by writing it into the frontend generated/ folder instead of frontend/. A user-provided frontend/index.html still overrides the default. TaskUpdateSettingsFile exposes the resolved path as clientIndexHtmlSource so vite.generated.ts picks up whichever file actually exists. At runtime, FrontendUtils falls back to frontend/generated/ when serving via vite (which returns 404 for files outside its root) or when reading directly from disk in dev-bundle mode.
Vite's HTML inputs preserve their relative path from the project root, so an index.html generated into frontend/generated/ was emitted as target/.../webapp/generated/index.html. The stats plugin and the Java-side consumers expect it at target/.../webapp/index.html, which broke the dev-bundle build. transformIndexHtml's '/index.html' check also skipped script injection in that case. Compute the source's relative path from the vite root, use it in the transformIndexHtml check, and rename the bundled asset back to index.html in generateBundle.
The previous attempt used `generateBundle` to rename the HTML asset, but rolldown emits HTML files outside the bundle object (they only exist on disk), so the rename never fired and the stats plugin still crashed reading target/.../webapp/index.html. Switch to `writeBundle`, which runs after the HTML has been emitted to disk and before the stats plugin's `enforce: 'post'` writeBundle hook. Also strip the leading `../` from src/href URLs that rolldown added to climb out of generated/, since after the move the HTML lives at the build output root.
b1e5fa1 to
d152c64
Compare
|
Test Results 1 425 files - 22 1 425 suites - 22 1h 7m 31s ⏱️ - 18m 3s For more details on these failures and errors, see this check. Results for commit d152c64. ± Comparison against base commit f5a0ba9. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Hide the Vaadin-generated index.html from source control by writing it into the frontend generated/ folder instead of frontend/. A user-provided frontend/index.html still overrides the default.
TaskUpdateSettingsFile exposes the resolved path as clientIndexHtmlSource so vite.generated.ts picks up whichever file actually exists. At runtime, FrontendUtils falls back to frontend/generated/ when serving via vite (which returns 404 for files outside its root) or when reading directly from disk in dev-bundle mode.