fix(vite): do not watch ignored pathes (#5632)

This commit is contained in:
Ahad Birang 2022-06-27 14:06:31 +02:00 committed by GitHub
parent 6f8b7a9043
commit 67f40d7e40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import { resolve, join, normalize } from 'pathe'
import * as vite from 'vite'
import vuePlugin from '@vitejs/plugin-vue'
import viteJsxPlugin from '@vitejs/plugin-vue-jsx'
import { logger, resolveModule } from '@nuxt/kit'
import { logger, resolveModule, isIgnored } from '@nuxt/kit'
import fse from 'fs-extra'
import { debounce } from 'perfect-debounce'
import { withoutTrailingSlash } from 'ufo'
@ -71,6 +71,9 @@ export async function buildServer (ctx: ViteBuildContext) {
rollupWarn(warning)
}
}
},
watch: {
exclude: ctx.nuxt.options.ignore
}
},
server: {
@ -176,7 +179,7 @@ export async function buildServer (ctx: ViteBuildContext) {
// Watch
viteServer.watcher.on('all', (_event, file) => {
file = normalize(file) // Fix windows paths
if (file.indexOf(ctx.nuxt.options.buildDir) === 0) { return }
if (file.indexOf(ctx.nuxt.options.buildDir) === 0 || isIgnored(file)) { return }
doBuild()
})
// ctx.nuxt.hook('builder:watch', () => doBuild())