docs: fix nuxt.config.ts configuration for auto-import components directories (#154)

* docs: fix `nuxt.config.ts` components installiation step

* docs: add `pathPrefix`: false
This commit is contained in:
Sadegh Barati 2023-11-09 13:42:22 +03:30 committed by GitHub
parent 4fcfb4edf2
commit a2c5834255
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,23 +28,33 @@ npm install -D @nuxtjs/tailwindcss
### Configure `nuxt.config.ts`
<Callout class="mt-4">
**Tip:** It's better to use Nuxt `components:dirs` hook to extend auto-import components directories.
If you use `components` key in `nuxt.config.ts` default config will disposed
</Callout>
```ts
export default defineNuxtConfig({
modules: ['@nuxtjs/tailwindcss'],
components: [
{
hooks: {
'components:dirs': (dirs) => {
dirs.unshift({
path: '~/components/ui',
// this is required else Nuxt will autoImport `.ts` file
extensions: ['.vue'],
// prefix for your components, eg: UiButton
prefix: 'Ui'
},
],
prefix: 'Ui',
// prevent adding another prefix component by it's path.
pathPrefix: false
})
}
}
})
```
### Run the CLI
Run the `shadcn-vue` init command to setup your project: