mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(vite): add type-checker to client build for ssr: false
(#7930)
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
This commit is contained in:
parent
6d3dc3b280
commit
d25dafef49
@ -1,4 +1,3 @@
|
||||
import { resolveTSConfig } from 'pkg-types'
|
||||
import { resolve } from 'pathe'
|
||||
import * as vite from 'vite'
|
||||
import vuePlugin from '@vitejs/plugin-vue'
|
||||
@ -142,16 +141,6 @@ export async function buildServer (ctx: ViteBuildContext) {
|
||||
})
|
||||
}
|
||||
|
||||
// Add type-checking
|
||||
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)
|
||||
serverConfig.plugins!.push(checker({
|
||||
vueTsc: {
|
||||
tsconfigPath: await resolveTSConfig(ctx.nuxt.options.rootDir)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
await ctx.nuxt.callHook('vite:extendConfig', serverConfig, { isClient: false, isServer: true })
|
||||
|
||||
const onBuild = () => ctx.nuxt.callHook('build:resources', wpfs)
|
||||
|
@ -2,12 +2,13 @@ import * as vite from 'vite'
|
||||
import { join, resolve } from 'pathe'
|
||||
import type { Nuxt } from '@nuxt/schema'
|
||||
import type { InlineConfig, SSROptions } from 'vite'
|
||||
import { logger, isIgnored, resolvePath } from '@nuxt/kit'
|
||||
import { logger, isIgnored, resolvePath, addVitePlugin } from '@nuxt/kit'
|
||||
import type { Options } from '@vitejs/plugin-vue'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
import { sanitizeFilePath } from 'mlly'
|
||||
import { withoutLeadingSlash } from 'ufo'
|
||||
import { filename } from 'pathe/utils'
|
||||
import { resolveTSConfig } from 'pkg-types'
|
||||
import { buildClient } from './client'
|
||||
import { buildServer } from './server'
|
||||
import virtual from './plugins/virtual'
|
||||
@ -102,6 +103,16 @@ export async function bundle (nuxt: Nuxt) {
|
||||
|
||||
await nuxt.callHook('vite:extend', ctx)
|
||||
|
||||
// Add type-checking
|
||||
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)
|
||||
addVitePlugin(checker({
|
||||
vueTsc: {
|
||||
tsconfigPath: await resolveTSConfig(ctx.nuxt.options.rootDir)
|
||||
}
|
||||
}), { client: !nuxt.options.ssr, server: nuxt.options.ssr })
|
||||
}
|
||||
|
||||
nuxt.hook('vite:serverCreated', (server: vite.ViteDevServer, env) => {
|
||||
// Invalidate virtual modules when templates are re-generated
|
||||
ctx.nuxt.hook('app:templatesGenerated', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user