Fix Vite plugin to respect root option for index.html entries#1561
Merged
webpro merged 1 commit intowebpro-nl:mainfrom Feb 23, 2026
Merged
Fix Vite plugin to respect root option for index.html entries#1561webpro merged 1 commit intowebpro-nl:mainfrom
webpro merged 1 commit intowebpro-nl:mainfrom
Conversation
commit: |
webpro
reviewed
Feb 23, 2026
Member
webpro
left a comment
There was a problem hiding this comment.
Thanks, keep it coming buddy 😃 One comment I have.
| const viteRoot = toAbsolute(cfg.root ?? '.', options.cwd); | ||
| if (!seenRoots.has(viteRoot)) { | ||
| seenRoots.add(viteRoot); | ||
| for (const entry of await getIndexHtmlEntries(viteRoot)) inputs.add(entry); |
Member
There was a problem hiding this comment.
If we do getIndexHtmlEntries here, can we remove resolve from the Vite plugin? As we're executing resolveConfig from both plugins already.
Contributor
Author
There was a problem hiding this comment.
resolveConfig only runs when a config file exists. Without resolve, config-less Vite projects (like the vite3 fixture) would lose index.html entry detection.
Member
|
Thanks Azat! ✨ |
Member
|
🚀 This pull request is included in v5.86.0. See Release 5.86.0 for release notes. Using Knip in a commercial project? Please consider becoming a sponsor. |
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.
In one of my projects, Vite uses the
rootoption, soindex.htmlis not located at the project root. Because of this, Knip did not detect entries referenced fromindex.htmland incorrectly reported related files/dependencies as unused.This PR makes Knip respect Vite’s
rootoption when resolvingindex.htmlentries, and adds a test case for a custom root setup.