fix(schema,vite): respect vite.cacheDir if defined (#27628)

This commit is contained in:
Josh Dean 2024-06-15 14:02:57 -07:00 committed by GitHub
parent 345a8799f7
commit 88f0b4f420
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import { consola } from 'consola'
import { resolve } from 'pathe'
import { isTest } from 'std-env'
import { withoutLeadingSlash } from 'ufo'
import { defineUntypedSchema } from 'untyped'
@ -109,5 +110,8 @@ export default defineUntypedSchema({
},
},
},
cacheDir: {
$resolve: async (val, get) => val ?? resolve(await get('rootDir') as string, 'node_modules/.cache/vite'),
},
},
})

View File

@ -118,7 +118,7 @@ export async function buildClient (ctx: ViteBuildContext) {
'vue',
],
},
cacheDir: resolve(ctx.nuxt.options.rootDir, 'node_modules/.cache/vite', 'client'),
cacheDir: resolve(ctx.nuxt.options.rootDir, ctx.config.cacheDir ?? 'node_modules/.cache/vite', 'client'),
build: {
sourcemap: ctx.nuxt.options.sourcemap.client ? ctx.config.build?.sourcemap ?? ctx.nuxt.options.sourcemap.client : false,
manifest: 'manifest.json',

View File

@ -71,7 +71,7 @@ export async function buildServer (ctx: ViteBuildContext) {
/(nuxt|nuxt3|nuxt-nightly)\/(dist|src|app)/,
],
},
cacheDir: resolve(ctx.nuxt.options.rootDir, 'node_modules/.cache/vite', 'server'),
cacheDir: resolve(ctx.nuxt.options.rootDir, ctx.config.cacheDir ?? 'node_modules/.cache/vite', 'server'),
build: {
// we'll display this in nitro build output
reportCompressedSize: false,