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

View File

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