-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Feature Request: option for publicDir to override the default public root in dev mode #2587
Comments
We also hit this and it made me wish it was possible to just copy It feels counter intuitive that everything else paths the way you'd expect except for files in the I'd probably advocate for control of where |
(I do recognize that would lead to |
@patak-js Did this actually get addressed with that commit? I may have overlooked it but that seemed to be only changes related to Stylus. |
Nope. That's a typo in the commit message, they intended to close #2857, not this issue. Reopening. |
What's the rationale for this being a feature that the dev server currently works differently than production in this way? I was actually just coming here to report a bug when a member of my team imported some assets from the root directory instead of putting them in "public", which would have caused it to break in production had I not caught it. |
For now, vite will warn about the unexpected requests for |
I agree with @hyf0 here. After #4631, the main problem the new option is trying to solve shouldn't occur as the users will see a clear warning: Playground. We also discussed in a team meeting that the Vite server should keep working as an enhanced static server over the root directory, as this is part of the mental model of Vite. |
Is your feature request related to a problem? Please describe.
Currently, even though
publicDir
is set to a directory insidevite.config.js
, in addition to serving those files statically, all files in the current directory are also still served as static files in dev mode.For example, http://localhost:3000/package.json will always show the project's
package.json
regardless of thepublicDir
.Describe the solution you'd like
One of:
publicDir
is set (is this a breaking change?)Additional context
Some devs have tripped up and accidentally referenced
/public/image.png
in their code, which works in dev but breaks in production, as the project root is no longer served as static.The text was updated successfully, but these errors were encountered: