mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(nuxi): restart nuxt when distDir
is unlinked (#19131)
This commit is contained in:
parent
b3ce9566a1
commit
eaeb4f089d
@ -66,6 +66,8 @@ export default defineNuxtCommand({
|
||||
})
|
||||
|
||||
let currentNuxt: Nuxt
|
||||
let distWatcher: chokidar.FSWatcher
|
||||
|
||||
const showURL = () => {
|
||||
listener.showURL({
|
||||
// TODO: Normalize URL with trailing slash within schema
|
||||
@ -82,11 +84,20 @@ export default defineNuxtCommand({
|
||||
if (currentNuxt) {
|
||||
await currentNuxt.close()
|
||||
}
|
||||
if (distWatcher) {
|
||||
await distWatcher.close()
|
||||
}
|
||||
|
||||
currentNuxt = await loadNuxt({ rootDir, dev: true, ready: false })
|
||||
if (!isRestart) {
|
||||
showURL()
|
||||
}
|
||||
|
||||
distWatcher = chokidar.watch(resolve(currentNuxt.options.buildDir, 'dist'), { ignoreInitial: true, depth: 0 })
|
||||
distWatcher.on('unlinkDir', () => {
|
||||
dLoad(true, '.nuxt/dist directory has been removed')
|
||||
})
|
||||
|
||||
// Write manifest and also check if we need cache invalidation
|
||||
if (!isRestart) {
|
||||
const previousManifest = await loadNuxtManifest(currentNuxt.options.buildDir)
|
||||
|
Loading…
Reference in New Issue
Block a user