fix(vite): resolve tsconfig.json for vue-tsc type checker (#6069)

This commit is contained in:
Mohammad Hosein Feizi 2022-07-25 15:32:42 +04:30 committed by GitHub
parent 8d469e7f15
commit cccafd620f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import { resolveTSConfig } from 'pkg-types'
import { resolve, normalize } from 'pathe' import { resolve, 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'
@ -107,7 +108,11 @@ export async function buildServer (ctx: ViteBuildContext) {
// Add type-checking // Add type-checking
if (ctx.nuxt.options.typescript.typeCheck === true || (ctx.nuxt.options.typescript.typeCheck === 'build' && !ctx.nuxt.options.dev)) { if (ctx.nuxt.options.typescript.typeCheck === true || (ctx.nuxt.options.typescript.typeCheck === 'build' && !ctx.nuxt.options.dev)) {
const checker = await import('vite-plugin-checker').then(r => r.default) const checker = await import('vite-plugin-checker').then(r => r.default)
serverConfig.plugins.push(checker({ vueTsc: true })) serverConfig.plugins.push(checker({
vueTsc: {
tsconfigPath: await resolveTSConfig(ctx.nuxt.options.rootDir)
}
}))
} }
await ctx.nuxt.callHook('vite:extendConfig', serverConfig, { isClient: false, isServer: true }) await ctx.nuxt.callHook('vite:extendConfig', serverConfig, { isClient: false, isServer: true })