fix(nuxt,schema): resolve shared dir from config (#31091)

This commit is contained in:
Clayton Chew 2025-02-23 17:31:39 +08:00 committed by Daniel Roe
parent e7dbe72b0b
commit 82337d6f97
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B
3 changed files with 9 additions and 5 deletions

View File

@ -57,8 +57,8 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
continue
}
sharedDirs.add(resolve(layer.config.rootDir, 'shared', 'utils'))
sharedDirs.add(resolve(layer.config.rootDir, 'shared', 'types'))
sharedDirs.add(resolve(layer.config.rootDir, layer.config.dir?.shared ?? 'shared', 'utils'))
sharedDirs.add(resolve(layer.config.rootDir, layer.config.dir?.shared ?? 'shared', 'types'))
}
}

View File

@ -79,8 +79,8 @@ export default defineNuxtModule<Partial<ImportsOptions>>({
composablesDirs.push(resolve(layer.config.srcDir, 'utils'))
if (isNuxtV4) {
composablesDirs.push(resolve(layer.config.rootDir, 'shared', 'utils'))
composablesDirs.push(resolve(layer.config.rootDir, 'shared', 'types'))
composablesDirs.push(resolve(layer.config.rootDir, layer.config.dir?.shared ?? 'shared', 'utils'))
composablesDirs.push(resolve(layer.config.rootDir, layer.config.dir?.shared ?? 'shared', 'types'))
}
for (const dir of (layer.config.imports?.dirs ?? [])) {

View File

@ -405,7 +405,11 @@ export default defineResolvers({
/**
* The shared directory. This directory is shared between the app and the server.
*/
shared: 'shared',
shared: {
$resolve: (val) => {
return val && typeof val === 'string' ? val : 'shared'
},
},
/**
* The directory containing your static files, which will be directly accessible via the Nuxt server