Netlify dev + SPA redirects + vite

Hi,

I need to disable netlify.toml redirects during local development with netlify dev for my SPA built with Vite, while keeping them for production. The redirects conflict with Vite’s routing in development. Vite is trying to reach all sorts of files like main.ts and they redirect to index.html and the app does not boot.

I understand there’s [context.production] category to be used in netlify.toml but it actually applies just fine during netlify dev if I’m working in the main branch, as I do.

I tried to nest [[redirect]] under [build] but that does not seem to work. Is there another way to define some redirects but don’t make them active during netlify dev ?

This must be a very common issue. Vite is popular and I assume people use it together with netlify dev.

Is there an easy way to solve this with netlify.toml or do I have to do some kind of workaround, such as generating _redirects and placing them in dist in CI?

There’s likely something else happening here. I use Vite wit Netlify CLI all the time and haven’t run into this issue.

Please share a reproduction repo so we can investigate.

ah okay! I’ll try to create a minimal reproduction