@@ -2,12 +2,13 @@ import * as vite from 'vite'
22import { join , resolve } from 'pathe'
33import type { Nuxt } from '@nuxt/schema'
44import type { InlineConfig , SSROptions } from 'vite'
5- import { logger , isIgnored , resolvePath } from '@nuxt/kit'
5+ import { logger , isIgnored , resolvePath , addVitePlugin } from '@nuxt/kit'
66import type { Options } from '@vitejs/plugin-vue'
77import replace from '@rollup/plugin-replace'
88import { sanitizeFilePath } from 'mlly'
99import { withoutLeadingSlash } from 'ufo'
1010import { filename } from 'pathe/utils'
11+ import { resolveTSConfig } from 'pkg-types'
1112import { buildClient } from './client'
1213import { buildServer } from './server'
1314import virtual from './plugins/virtual'
@@ -102,6 +103,16 @@ export async function bundle (nuxt: Nuxt) {
102103
103104 await nuxt . callHook ( 'vite:extend' , ctx )
104105
106+ // Add type-checking
107+ if ( ctx . nuxt . options . typescript . typeCheck === true || ( ctx . nuxt . options . typescript . typeCheck === 'build' && ! ctx . nuxt . options . dev ) ) {
108+ const checker = await import ( 'vite-plugin-checker' ) . then ( r => r . default )
109+ addVitePlugin ( checker ( {
110+ vueTsc : {
111+ tsconfigPath : await resolveTSConfig ( ctx . nuxt . options . rootDir )
112+ }
113+ } ) , { client : ! nuxt . options . ssr , server : nuxt . options . ssr } )
114+ }
115+
105116 nuxt . hook ( 'vite:serverCreated' , ( server : vite . ViteDevServer , env ) => {
106117 // Invalidate virtual modules when templates are re-generated
107118 ctx . nuxt . hook ( 'app:templatesGenerated' , ( ) => {
0 commit comments