mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 01:17:16 +00:00
fix(nuxt3): respect srcDir
and normalize string in component dirs (#3815)
Co-authored-by: pooya parsa <pyapar@gmail.com>
This commit is contained in:
parent
ae364f95cc
commit
f3168d923b
@ -33,22 +33,16 @@ export default defineNuxtModule<ComponentsOptions>({
|
|||||||
}
|
}
|
||||||
if (typeof dir === 'string') {
|
if (typeof dir === 'string') {
|
||||||
return {
|
return {
|
||||||
path: resolve(cwd, resolveAlias(dir, {
|
path: resolve(cwd, resolveAlias(dir))
|
||||||
...nuxt.options.alias,
|
|
||||||
'~': cwd
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
const dirs = (dir.dirs || [dir]).filter(_dir => _dir.path)
|
const dirs = (dir.dirs || [dir]).map(dir => typeof dir === 'string' ? { path: dir } : dir).filter(_dir => _dir.path)
|
||||||
return dirs.map(_dir => ({
|
return dirs.map(_dir => ({
|
||||||
..._dir,
|
..._dir,
|
||||||
path: resolve(cwd, resolveAlias(_dir.path, {
|
path: resolve(cwd, resolveAlias(_dir.path))
|
||||||
...nuxt.options.alias,
|
|
||||||
'~': cwd
|
|
||||||
}))
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +50,7 @@ export default defineNuxtModule<ComponentsOptions>({
|
|||||||
nuxt.hook('app:resolve', async () => {
|
nuxt.hook('app:resolve', async () => {
|
||||||
// components/ dirs from all layers
|
// components/ dirs from all layers
|
||||||
const allDirs = nuxt.options._layers
|
const allDirs = nuxt.options._layers
|
||||||
.map(layer => normalizeDirs(layer.config.components, layer.cwd))
|
.map(layer => normalizeDirs(layer.config.components, layer.config.srcDir))
|
||||||
.flat()
|
.flat()
|
||||||
|
|
||||||
await nuxt.callHook('components:dirs', allDirs)
|
await nuxt.callHook('components:dirs', allDirs)
|
||||||
|
Loading…
Reference in New Issue
Block a user