mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(vite,webpack): don't add type checker/analyzer when testing (#24608)
This commit is contained in:
parent
4981e3259d
commit
1e393ad696
@ -82,7 +82,7 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
||||
esbuild: {
|
||||
options: { exclude: excludePattern }
|
||||
},
|
||||
analyze: nuxt.options.build.analyze && (nuxt.options.build.analyze === true || nuxt.options.build.analyze.enabled)
|
||||
analyze: !nuxt.options.test && nuxt.options.build.analyze && (nuxt.options.build.analyze === true || nuxt.options.build.analyze.enabled)
|
||||
? {
|
||||
template: 'treemap',
|
||||
projectRoot: nuxt.options.rootDir,
|
||||
|
@ -130,12 +130,12 @@ export async function buildClient (ctx: ViteBuildContext) {
|
||||
}
|
||||
|
||||
// Add analyze plugin if needed
|
||||
if (ctx.nuxt.options.build.analyze && (ctx.nuxt.options.build.analyze === true || ctx.nuxt.options.build.analyze.enabled)) {
|
||||
if (!ctx.nuxt.options.test && ctx.nuxt.options.build.analyze && (ctx.nuxt.options.build.analyze === true || ctx.nuxt.options.build.analyze.enabled)) {
|
||||
clientConfig.plugins!.push(...await import('./plugins/analyze').then(r => r.analyzePlugin(ctx)))
|
||||
}
|
||||
|
||||
// Add type checking client panel
|
||||
if (ctx.nuxt.options.typescript.typeCheck === true && ctx.nuxt.options.dev) {
|
||||
if (!ctx.nuxt.options.test && ctx.nuxt.options.typescript.typeCheck === true && ctx.nuxt.options.dev) {
|
||||
clientConfig.plugins!.push(typeCheckPlugin({ sourcemap: !!ctx.nuxt.options.sourcemap.client }))
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => {
|
||||
}
|
||||
|
||||
// Add type-checking
|
||||
if (ctx.nuxt.options.typescript.typeCheck === true || (ctx.nuxt.options.typescript.typeCheck === 'build' && !ctx.nuxt.options.dev)) {
|
||||
if (!ctx.nuxt.options.test && (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: {
|
||||
|
@ -83,7 +83,7 @@ function clientOptimization (_ctx: WebpackConfigContext) {
|
||||
function clientPlugins (ctx: WebpackConfigContext) {
|
||||
// webpack Bundle Analyzer
|
||||
// https://github.com/webpack-contrib/webpack-bundle-analyzer
|
||||
if (!ctx.isDev && ctx.name === 'client' && ctx.userConfig.analyze && (ctx.userConfig.analyze === true || ctx.userConfig.analyze.enabled)) {
|
||||
if (!ctx.isDev && !ctx.nuxt.options.test && ctx.name === 'client' && ctx.userConfig.analyze && (ctx.userConfig.analyze === true || ctx.userConfig.analyze.enabled)) {
|
||||
const statsDir = resolve(ctx.options.analyzeDir)
|
||||
|
||||
ctx.config.plugins!.push(new BundleAnalyzerPlugin({
|
||||
@ -100,7 +100,7 @@ function clientPlugins (ctx: WebpackConfigContext) {
|
||||
// Normally type checking runs in server config, but in `ssr: false` there is
|
||||
// no server build, so we inject here instead.
|
||||
if (!ctx.nuxt.options.ssr) {
|
||||
if (ctx.nuxt.options.typescript.typeCheck === true || (ctx.nuxt.options.typescript.typeCheck === 'build' && !ctx.nuxt.options.dev)) {
|
||||
if (!ctx.nuxt.options.test && (ctx.nuxt.options.typescript.typeCheck === true || (ctx.nuxt.options.typescript.typeCheck === 'build' && !ctx.nuxt.options.dev))) {
|
||||
ctx.config.plugins!.push(new ForkTSCheckerWebpackPlugin({
|
||||
logger
|
||||
}))
|
||||
|
@ -89,7 +89,7 @@ function serverPlugins (ctx: WebpackConfigContext) {
|
||||
}
|
||||
|
||||
// Add type-checking
|
||||
if (ctx.nuxt.options.typescript.typeCheck === true || (ctx.nuxt.options.typescript.typeCheck === 'build' && !ctx.nuxt.options.dev)) {
|
||||
if (!ctx.nuxt.options.test && (ctx.nuxt.options.typescript.typeCheck === true || (ctx.nuxt.options.typescript.typeCheck === 'build' && !ctx.nuxt.options.dev))) {
|
||||
ctx.config.plugins!.push(new ForkTSCheckerWebpackPlugin({
|
||||
logger
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user