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
fix(dev): watch publicDir explicitly to include it outside the root #16502
Merged
Conversation
This file contains 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
Run & review this pull request in StackBlitz Codeflow. |
7 tasks
patak-dev
added
regression
The issue only appears after a new release
feat: dev
dev server
p3-minor-bug
An edge case that only affects very specific usage (priority)
labels
Apr 22, 2024
patak-dev
approved these changes
Apr 22, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! Looks good to me.
sapphi-red
approved these changes
Apr 23, 2024
danroux
pushed a commit
to danroux/sk8l-ui
that referenced
this pull request
May 8, 2024
## 5.2.11 (2024-05-02) * feat: improve dynamic import variable failure error message (#16519) ([f8feeea](vitejs/vite@f8feeea)), closes [#16519](vitejs/vite#16519) * fix: dynamic-import-vars plugin normalize path issue (#16518) ([f71ba5b](vitejs/vite@f71ba5b)), closes [#16518](vitejs/vite#16518) * fix: scripts and styles were missing from built HTML on Windows (#16421) ([0e93f58](vitejs/vite@0e93f58)), closes [#16421](vitejs/vite#16421) * fix(deps): update all non-major dependencies (#16488) ([2d50be2](vitejs/vite@2d50be2)), closes [#16488](vitejs/vite#16488) * fix(deps): update all non-major dependencies (#16549) ([2d6a13b](vitejs/vite@2d6a13b)), closes [#16549](vitejs/vite#16549) * fix(dev): watch publicDir explicitly to include it outside the root (#16502) ([4d83eb5](vitejs/vite@4d83eb5)), closes [#16502](vitejs/vite#16502) * fix(preload): skip preload for non-static urls (#16556) ([bb79c9b](vitejs/vite@bb79c9b)), closes [#16556](vitejs/vite#16556) * fix(ssr): handle class declaration and expression name scoping (#16569) ([c071eb3](vitejs/vite@c071eb3)), closes [#16569](vitejs/vite#16569) * fix(ssr): handle function expression name scoping (#16563) ([02db947](vitejs/vite@02db947)), closes [#16563](vitejs/vite#16563) ## 5.2.10 (2024-04-20) * revert: perf: use workspace root for fs cache (#15712) (#16476) ([77e7359](vitejs/vite@77e7359)), closes [#15712](vitejs/vite#15712) [#16476](vitejs/vite#16476) * fix: add base to virtual html (#16442) ([721f94d](vitejs/vite@721f94d)), closes [#16442](vitejs/vite#16442) * fix: adjust esm syntax judgment logic (#16436) ([af72eab](vitejs/vite@af72eab)), closes [#16436](vitejs/vite#16436) * fix: don't add outDirs to watch.ignored if emptyOutDir is false (#16453) ([6a127d6](vitejs/vite@6a127d6)), closes [#16453](vitejs/vite#16453) * fix(cspNonce): don't overwrite existing nonce values (#16415) ([b872635](vitejs/vite@b872635)), closes [#16415](vitejs/vite#16415) * feat: show warning if root is in build.outDir (#16454) ([11444dc](vitejs/vite@11444dc)), closes [#16454](vitejs/vite#16454) * feat: write cspNonce to style tags (#16419) ([8e54bbd](vitejs/vite@8e54bbd)), closes [#16419](vitejs/vite#16419) * chore(deps): update dependency eslint-plugin-n to v17 (#16381) ([6cccef7](vitejs/vite@6cccef7)), closes [#16381](vitejs/vite#16381)
danroux
pushed a commit
to danroux/sk8l-ui
that referenced
this pull request
May 8, 2024
## 5.2.11 (2024-05-02) * feat: improve dynamic import variable failure error message (#16519) ([f8feeea](vitejs/vite@f8feeea)), closes [#16519](vitejs/vite#16519) * fix: dynamic-import-vars plugin normalize path issue (#16518) ([f71ba5b](vitejs/vite@f71ba5b)), closes [#16518](vitejs/vite#16518) * fix: scripts and styles were missing from built HTML on Windows (#16421) ([0e93f58](vitejs/vite@0e93f58)), closes [#16421](vitejs/vite#16421) * fix(deps): update all non-major dependencies (#16488) ([2d50be2](vitejs/vite@2d50be2)), closes [#16488](vitejs/vite#16488) * fix(deps): update all non-major dependencies (#16549) ([2d6a13b](vitejs/vite@2d6a13b)), closes [#16549](vitejs/vite#16549) * fix(dev): watch publicDir explicitly to include it outside the root (#16502) ([4d83eb5](vitejs/vite@4d83eb5)), closes [#16502](vitejs/vite#16502) * fix(preload): skip preload for non-static urls (#16556) ([bb79c9b](vitejs/vite@bb79c9b)), closes [#16556](vitejs/vite#16556) * fix(ssr): handle class declaration and expression name scoping (#16569) ([c071eb3](vitejs/vite@c071eb3)), closes [#16569](vitejs/vite#16569) * fix(ssr): handle function expression name scoping (#16563) ([02db947](vitejs/vite@02db947)), closes [#16563](vitejs/vite#16563) ## 5.2.10 (2024-04-20) * revert: perf: use workspace root for fs cache (#15712) (#16476) ([77e7359](vitejs/vite@77e7359)), closes [#15712](vitejs/vite#15712) [#16476](vitejs/vite#16476) * fix: add base to virtual html (#16442) ([721f94d](vitejs/vite@721f94d)), closes [#16442](vitejs/vite#16442) * fix: adjust esm syntax judgment logic (#16436) ([af72eab](vitejs/vite@af72eab)), closes [#16436](vitejs/vite#16436) * fix: don't add outDirs to watch.ignored if emptyOutDir is false (#16453) ([6a127d6](vitejs/vite@6a127d6)), closes [#16453](vitejs/vite#16453) * fix(cspNonce): don't overwrite existing nonce values (#16415) ([b872635](vitejs/vite@b872635)), closes [#16415](vitejs/vite#16415) * feat: show warning if root is in build.outDir (#16454) ([11444dc](vitejs/vite@11444dc)), closes [#16454](vitejs/vite#16454) * feat: write cspNonce to style tags (#16419) ([8e54bbd](vitejs/vite@8e54bbd)), closes [#16419](vitejs/vite#16419) * chore(deps): update dependency eslint-plugin-n to v17 (#16381) ([6cccef7](vitejs/vite@6cccef7)), closes [#16381](vitejs/vite#16381)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
feat: dev
dev server
p3-minor-bug
An edge case that only affects very specific usage (priority)
regression
The issue only appears after a new release
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
There is an optimization in place for the
publicDir
, where the watcher keeps a live list of all the files that are in the public directory, and only serves static content at paths it knows to be part of the public directory by checking that list.The bug occurs when the public directory is outside of the root directory. That causes it not to be watched by the current chokidar configuration. Because it is not watched, that live public files list is never updated after the server starts, which means that new files are not added to the list. Because the new files are not added to the list, the dev server static middleware will not attempt to serve them as static files.
This fix just explicitly adds the
publicDir
to the watch list, which has no effect if the public directory is inside the root, but fixes the expected behavior if the public directory is outside the root.I didn't update the
server.watch
documentation, because it doesn't appear to be exhaustive about the watch list currently. It doesn't mention dotenv files or vite config dependencies.fixes #16503
Checklist
[x] Read the Contributing Guidelines at https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md.
[x] Check that there isn't already a PR that solves the problem the same way. If you find a duplicate, please help us reviewing it.
[x] Update the corresponding documentation if needed.
[x] Include relevant tests that fail without this PR but pass with it.