mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 17:07:22 +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 currentNuxt: Nuxt
|
||||||
|
let distWatcher: chokidar.FSWatcher
|
||||||
|
|
||||||
const showURL = () => {
|
const showURL = () => {
|
||||||
listener.showURL({
|
listener.showURL({
|
||||||
// TODO: Normalize URL with trailing slash within schema
|
// TODO: Normalize URL with trailing slash within schema
|
||||||
@ -82,11 +84,20 @@ export default defineNuxtCommand({
|
|||||||
if (currentNuxt) {
|
if (currentNuxt) {
|
||||||
await currentNuxt.close()
|
await currentNuxt.close()
|
||||||
}
|
}
|
||||||
|
if (distWatcher) {
|
||||||
|
await distWatcher.close()
|
||||||
|
}
|
||||||
|
|
||||||
currentNuxt = await loadNuxt({ rootDir, dev: true, ready: false })
|
currentNuxt = await loadNuxt({ rootDir, dev: true, ready: false })
|
||||||
if (!isRestart) {
|
if (!isRestart) {
|
||||||
showURL()
|
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
|
// Write manifest and also check if we need cache invalidation
|
||||||
if (!isRestart) {
|
if (!isRestart) {
|
||||||
const previousManifest = await loadNuxtManifest(currentNuxt.options.buildDir)
|
const previousManifest = await loadNuxtManifest(currentNuxt.options.buildDir)
|
||||||
|
Loading…
Reference in New Issue
Block a user