-
-
Notifications
You must be signed in to change notification settings - Fork 372
How do we add prefix for all components? #438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Would be nice.
Does not work. The resolver is only for resolving the path. |
Do you have found a solution? I also want to prefix all my components. For example:
|
The returned object also needs a "from" property. |
any updates? |
did anyone get this to work? |
It requires some coding changes for this to work. The way component resoution works is that a component map is generated from your There's no options, transforms, filters or callbacks that have any ability to affect this component map creation. Technically speaking, for an MVP, all you would need to do is insert a prefix here: unplugin-vue-components/src/core/context.ts Line 228 in 63d5c7e
before the There's a pull request (#612) that's been languishing for over 2 years, so I doubt anything is ever going to happen in implementing this feature. There's a pretty easy workaround though... just put all your components inside a subfolder with your prefix as its name and then enable |
You can create a custom resolver adding the prefix option, check this resolver to allow prefixing all Vuetify components using VuetifyXXX instead VXXX (we only allow prefix as a boolean, but you can allow any prefix, the logic in that case should be changed): |
The problem with using a custom resolver is that you lose access to all the filters like You have to reimplement everything yourself. It’d be far preferable to be able to specify a prefix for components in the vite plug-in config. |
then, why do you need to add a prefix? |
Asking “why” is a strange question for software development. A plug-in like this has thousands of users with complex, unpredictable and varied needs in infinite different contexts. “Why not” is always the better question. Personally, it’s a DX issue where it helps to quickly know where a component is coming from if I’m using them from many different sources in the same project. But others might have more functionality-based needs. |
|
Because you suggested using a custom resolver to add a prefix to local components… |
Oh, sorry, this issue is about prefixing local components without using directory as namespace option, I will try to add the prefix feature. |
I'm trying to add prefixes to all components. And I can't find how to do it?
Could you somehow add it as a feature?
Thanks a lot
The text was updated successfully, but these errors were encountered: