feat(config): add entryRoot
option
#16629
Draft
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
The
entryRoot
option allows customization of Vite's dev server and its Rollup build.For the dev server, it determines the root directory used by the
htmlFallbackMiddleware
andindexHtmlMiddleware
handlers. This means I can place myindex.html
file in thesrc
directory and Vite will resolve/
requests to it as long as I setentryRoot: "src"
in my Vite config. In the same scenario, any other.html
files in mysrc
directory will be resolved as expected./foo
is requested, the dev server will look for thesrc/foo.html
file. When/foo/
is requested, it looks forsrc/foo/index.html
file. Previously, the dev server would look in the project root, so I would need a./foo
directory instead of a./src/foo
directory (not ideal).For the Rollup build,
entryRoot
determines the root directory from which the defaultindex.html
entry is resolved. Thelib.entry
andssr
options are also resolved this way.Note that if the
entryRoot
is not absolute, it's resolved like so:Opening this PR as a draft since I haven't written tests or updated the docs. Also I'd like some feedback before doing those things.
Fixes #306