vuetify-nuxt-module icon indicating copy to clipboard operation
vuetify-nuxt-module copied to clipboard

Aliases don't seem to work when defined in blueprints

Open daniandl opened this issue 2 years ago • 3 comments

https://stackblitz.com/edit/nuxt-starter-5qj9ao?file=nuxt.config.ts

Defaults work, but components inside aliases have a Component is missing template or render function warning and don't render. From a quick look at source code, I think it's because they don't get mapped to the components properly like the regular aliases config property.

Current hack solution

// vuetify.config.ts
...
blueprint: {
  defaults: blueprint.defaults,
},
aliases: blueprint.aliases,
...
// blueprint.ts
import type { ComponentName } from 'vuetify-nuxt-module'

export default {
  aliases: {
   MyBtn: 'VBtn',
  } as Record<string, ComponentName>,
  ...
}

Bonus tip for anyone dealing with Typescript and needing Intellisense on your virtual components:

declare module '@vue/runtime-dom' {
  export interface GlobalComponents {
    MyBtn: typeof import('vuetify/components')['VBtn']
  }
}

daniandl avatar Nov 19 '23 14:11 daniandl

Check the docs, you cannot use Vuetify blueprints, it has some limitations, I need to review the logic.

I'll check if I can register global aliases.

userquin avatar Nov 22 '23 19:11 userquin

Check the docs, you cannot use Vuetify blueprints, it has some limitations, I need to review the logic.

I'll check if I can register global aliases.

According to the docs, you can use blueprints, though. https://vuetify-nuxt-module.netlify.app/guide/vuetify-blueprints.html

It says aliases can be used if used with string components. If this is not possible, the aliases option should be marked as unsupported.

daniandl avatar Nov 23 '23 10:11 daniandl

Do you want me to close this? It has been a year and the docs are still the same.

daniandl avatar Oct 30 '24 17:10 daniandl