feat(config): add `entryRoot` option
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
htmlFallbackMiddlewareandindexHtmlMiddlewarehandlers. This means I can place myindex.htmlfile in thesrcdirectory and Vite will resolve/requests to it as long as I setentryRoot: "src"in my Vite config. In the same scenario, any other.htmlfiles in mysrcdirectory will be resolved as expected.- For example, when
/foois requested, the dev server will look for thesrc/foo.htmlfile. When/foo/is requested, it looks forsrc/foo/index.htmlfile. Previously, the dev server would look in the project root, so I would need a./foodirectory instead of a./src/foodirectory (not ideal).
- For example, when
-
For the Rollup build,
entryRootdetermines the root directory from which the defaultindex.htmlentry is resolved. Thelib.entryandssroptions 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
Run & review this pull request in StackBlitz Codeflow.