[general/netlify integration] nitro dev
should delete build artifacts generated by previous nitro build
#1970
Labels
nitro dev
should delete build artifacts generated by previous nitro build
#1970
Describe the feature
I'll start with a specific problem, and then generalise to what the broader gap is in my view.
Given a Nitro-powered project, when running
netlify build
and thennetlify dev
, the Netlify Dev environment will pick up build artifacts like.netlify/functions-internal/server
anddist/_redirect
and run them as part of the dev environment. This breaks the dev environment, because those artifacts are from an old build. What should be happening instead is that the Netlify Dev environment proxies all requests to the Nitro Dev server.There's multiple ways to fix this. One possible fix within Nitro would be to clear all artifacts generated during build on startup of the Nitro Dev server. We could also look at working around this on the Netlify Dev side, although this would probably be workaround that's specific to Nitro - which is always brittle.
The broader gap, in my view, is that Nitro presets only concern themselves with a hosting provider's deployment step (build output etc), but not with the development step.
In the code, you can see this in the fact that the dev server will alway run the
nitro-dev
preset: https://github.com/unjs/nitro/blob/48c79556b8588d392adfde35faf5c040e2465cf1/src/cli/commands/dev.ts#L37My idea for how to fix this is to run provider detection in the dev server, and to use that second preset to call hooks specific to local dev. To fix the specific problem i'm reporting, an
onPreDev
hook could be added to the Netlify preset, which clears any existing build artifacts.Additional information
The text was updated successfully, but these errors were encountered: