The 'standard' for writing a vue component library #9545
-
Im attempting to write a reusable component library which is full of vue SFCs and built using vite so I can view them in storybook.
main.ts would be the export for the plugin, containing the How would I go about actually building this as a package so that users can just install the plugin and have all the components + typings. I've got to a point where the plugin exists, and all of my components register when I use the plugin but I have no typings which makes the DX horrible. Is there any starter template for these type of component libraries / examples I can look at? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I have this starter template: https://github.com/LinusBorg/vue-lib-template It's a bit overengineered as a monorepo with a playground app and vitepress docs as separate packages. But converning the build setup, types etc. you can look into the /packages/lib directory and will find a good starting point. |
Beta Was this translation helpful? Give feedback.
Here's where I build the lib's type for production.
https://github.com/LinusBorg/vue-lib-template/blob/ffabdf3212cfdd57056428dbf7eca0105719c19a/packages/lib/package.json#L32
Also check the other options in package.json for the correct exports of those types.
The playground app doesnt rely on those as its vite config aliases the
lib
package directly to the lib's src entrypoint during dev, so we don't need to build the lib for the playground.