mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
docs: add note about nested directory order (#19061)
This commit is contained in:
parent
80f73d39ce
commit
6c5d8d6b2b
@ -27,13 +27,30 @@ Nuxt automatically imports any components in your `components/` directory (along
|
||||
</template>
|
||||
```
|
||||
|
||||
## Custom directories
|
||||
|
||||
By default, only the `~/components` directory is scanned. If you want to add other directories, or change how the components are scanned within a subfolder of this directory, you can add additional directories to the configuration:
|
||||
|
||||
```js
|
||||
export default defineNuxtConfig({
|
||||
components: [
|
||||
{ '~/components/special-components', prefix: 'Special' },
|
||||
'~/components',
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
::alert
|
||||
Any nested directories need to be added first as they are scanned in order.
|
||||
::
|
||||
|
||||
## Component extensions
|
||||
|
||||
By default, any file with an extension specified in the [extensions key of `nuxt.config.ts`](/api/configuration/nuxt-config#extensions) is treated as a component.
|
||||
If you need to restrict the file extensions that should be registered as components, you can use the extended form of the components directory declaration and its `extensions` key:
|
||||
|
||||
```diff
|
||||
export default defineNuxtModule({
|
||||
export default defineNuxtConfig({
|
||||
components: [
|
||||
{
|
||||
path: '~/components',
|
||||
@ -70,7 +87,7 @@ If you want to auto-import components based only on its name, not path, then you
|
||||
export default defineNuxtConfig({
|
||||
components: [
|
||||
{
|
||||
path: '~/components/',
|
||||
path: '~/components',
|
||||
+ pathPrefix: false,
|
||||
},
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user