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 GitHub
parent ed3b9815cd
commit d1733365f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View File

@ -57,8 +57,8 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
continue continue
} }
sharedDirs.add(resolve(layer.config.rootDir, 'shared', 'utils')) sharedDirs.add(resolve(layer.config.rootDir, layer.config.dir?.shared ?? 'shared', 'utils'))
sharedDirs.add(resolve(layer.config.rootDir, 'shared', 'types')) 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')) composablesDirs.push(resolve(layer.config.srcDir, 'utils'))
if (isNuxtV4) { if (isNuxtV4) {
composablesDirs.push(resolve(layer.config.rootDir, 'shared', 'utils')) composablesDirs.push(resolve(layer.config.rootDir, layer.config.dir?.shared ?? 'shared', 'utils'))
composablesDirs.push(resolve(layer.config.rootDir, 'shared', 'types')) composablesDirs.push(resolve(layer.config.rootDir, layer.config.dir?.shared ?? 'shared', 'types'))
} }
for (const dir of (layer.config.imports?.dirs ?? [])) { 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. * 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 * The directory containing your static files, which will be directly accessible via the Nuxt server