-
Notifications
You must be signed in to change notification settings - Fork 10
fix!: only serve dev static assets from publish dir as fallback #508
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
base: main
Are you sure you want to change the base?
Conversation
|
@copilot what does this have to do with SPAs and redirects? did you cross wires with another issue? also, can you compare this with the behaviour implemented in https://github.com/netlify/cli/? when does it use static files in the publish dir during dev? |
The SPA redirect is directly related to the issue. Here's how:
Without the SPA redirect, the issue would still exist but be less obvious - direct requests for files that exist in both dist and source would serve from dist. Regarding comparison with Netlify CLI: The CLI doesn't integrate with Vite's dev server, so it doesn't have this conflict. During Commit: 71ed852 |
When using `@netlify/vite-plugin`, `vite dev` (or e.g. `astro dev`) was incorrectly serving files from the Netlify publish dir (e.g. `dist/`) instead of the source directory during vite dev. I can't think of any reason to ever augment the directories passed to `@netlify/dev`'s options with the default directory. In every known use case (`@netlify/vite-plugin`, `@netlify/nuxt`...), we pass a known set of directories that should be used to serve static assets in dev. It seems reasonable to use some reasonable defaults here for future use cases. This commit makes this change. Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com>
71ed852 to
3a6c743
Compare
Fixes #436
Problem
When using
@netlify/vite-plugin,vite dev(or e.g.astro dev) was incorrectly serving files from the Netlify publish dir (e.g.dist/) instead of the source directory during vite dev.This causes various problems, the most basic of which is that if you've ever previously run
vite build(or e.g. `astro build) your dev server scans the production build output dir and serves assets from it. This is confusing and incorrect.Solution
I can't think of any reason to ever augment the directories explicitly passed to
@netlify/dev's options with a default directory. In every known use case (@netlify/vite-plugin,@netlify/nuxt...), we pass the known, exhaustive set of directories that should be used to serve static assets in dev, so we should respect these as is.It seems reasonable to use some sensible defaults here when not provided (for hypothetical future or direct use cases).
This PR makes this change.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.