-
Notifications
You must be signed in to change notification settings - Fork 343
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: clear dist
directory before Dev for Nuxt
#6242
Conversation
src/utils/detect-server-settings.ts
Outdated
const useStaticServer = !(command && frameworkPort) | ||
|
||
// workaround for https://github.com/unjs/nitro/issues/1970 | ||
const clearDist = frameworkSettings.framework?.includes('Nuxt') |
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.
I'll be honest, I don't really like that we're storing this within the CLI. Should live within build-info, ideally - let me see if I can open a PR there.
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.
Here's a PR to add this info to build-info: netlify/build#5430
Turned this into draft until that landed.
I couldn't find an easy way of writing a test for this :/ |
@@ -38,12 +41,17 @@ export const startFrameworkServer = async function ({ cwd, settings }) { | |||
text: `Waiting for framework port ${settings.frameworkPort}. This can be configured using the 'targetPort' property in the netlify.toml`, | |||
}) | |||
|
|||
if (settings.clearPublishDirectory && settings.dist) { | |||
await rm(settings.dist, { recursive: true, force: true }) |
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.
this is the main change, all the rest is typescript conversion stuff
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.
haha I feel you just opened a just change types PR before performing the actual change
Part of https://linear.app/netlify/issue/COM-184/nuxt-netlify-dev-doesnt-work. Running
ntl build
and thenntl dev
on a Nuxt project leads to Dev picking updist/_redirects
anddist/_headers
, even though the Nitro dev server will handle all of this on its own. This is breaking local dev currently.In unjs/nitro#1970, the Nitro team suggests we add
rm -rf
to the dev command. I tried doing that in netlify/build#5429, but since we don't spawn a full shell for the dev process, we can't use command concatenation like&&
.This PR contains an alternative fix, where we manually remove the
dist
directory just for Nuxt projects.