Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): add entryRoot option #16629

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

aleclarson
Copy link
Member

@aleclarson aleclarson commented May 7, 2024

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 and indexHtmlMiddleware handlers. This means I can place my index.html file in the src directory and Vite will resolve / requests to it as long as I set entryRoot: "src" in my Vite config. In the same scenario, any other .html files in my src directory will be resolved as expected.

    • For example, when /foo is requested, the dev server will look for the src/foo.html file. When /foo/ is requested, it looks for src/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 default index.html entry is resolved. The lib.entry and ssr options are also resolved this way.

Note that if the entryRoot is not absolute, it's resolved like so:

path.resolve(config.root, entryRoot)

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

Copy link

stackblitz bot commented May 7, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possibility to change index.html location but keep root
1 participant