fix(nuxt3): normalize watched paths (#4133)

This commit is contained in:
Daniel Roe 2022-04-06 17:02:56 +01:00 committed by GitHub
parent b7dc0931c4
commit 540e23c7a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@ import chokidar from 'chokidar'
import type { Nuxt } from '@nuxt/schema'
import { importModule, isIgnored } from '@nuxt/kit'
import { debounce } from 'perfect-debounce'
import { normalize } from 'pathe'
import { createApp, generateApp as _generateApp } from './app'
export async function build (nuxt: Nuxt) {
@ -48,7 +49,7 @@ function watch (nuxt: Nuxt) {
]
})
const watchHook = debounce((event: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', path: string) => nuxt.callHook('builder:watch', event, path))
const watchHook = debounce((event: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', path: string) => nuxt.callHook('builder:watch', event, normalize(path)))
watcher.on('all', watchHook)
nuxt.hook('close', () => watcher.close())
return watcher