Skip to content

Commit

Permalink
docs: fix nuxt.config.ts configuration for auto-import components d…
Browse files Browse the repository at this point in the history
…irectories (#154)

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

* docs: add `pathPrefix`: false
  • Loading branch information
sadeghbarati authored Nov 9, 2023
1 parent 4fcfb4e commit a2c5834
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions apps/www/src/content/docs/installation/nuxt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
path: '~/components/ui',
// this is required else Nuxt will autoImport `.ts` file
extensions: ['.vue'],
// prefix for your components, eg: UiButton
prefix: 'Ui'
},
],
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',
// prevent adding another prefix component by it's path.
pathPrefix: false
})
}
}
})
```



### Run the CLI

Run the `shadcn-vue` init command to setup your project:
Expand Down Expand Up @@ -128,4 +138,4 @@ The command above will add the `Button` component to your project. Nuxt autoImpo
</template>
```

</Steps>
</Steps>

0 comments on commit a2c5834

Please sign in to comment.