Skip to content

Best practice to create a component library with vue #1060

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

Open
SvenBudak opened this issue May 20, 2021 · 1 comment
Open

Best practice to create a component library with vue #1060

SvenBudak opened this issue May 20, 2021 · 1 comment
Labels

Comments

@SvenBudak
Copy link

SvenBudak commented May 20, 2021

Currently (and also the last months) I found only tedious knowledge about how to create a component library with VueJS. I found tons of articles that were either outdated or left out basic features.

The best I found so far was a CLI to create component libraries: https://github.com/team-innovation/vue-sfc-rollup

This is a very good base, but it still uses the depricated node-sass instead of sass: https://www.npmjs.com/package/sass

And what I see as the biggest problem is that with vue-sfc-rollup you can't work with sass directly in the vue components. For example <style scoped lang="scss"> will not work. But it should, because you want to load component related styles only once the component is loaded. Here, you should definitely take automated care that the component styles are loaded only 1 time in the DOM, even if the component is loaded 100 times.

It would also be helpful if you could specify a sass / scss file that is ALWAYS loaded (for example to load a reset.css or normalize.css) and a sass / scss file that is always loaded when a component is loaded from the libary (could for example contain css variables that are necessary for the components).

This would massively reduce CSS overhead, developers would be more willing to invest time in developing high quality component libraries (which should greatly expand the ecosystem in a short time) and the performance of Vue applications would look much more attractive on paper.

If these problems can be solved, I would recommend to contact the developers of vue-sfc-rollup if they would be interested in integrating their CLI directly into the VueCLI. Or allow to integrate them. Similar to what is possible with Angular, for example: https://angular.io/guide/creating-libraries (Which works wonderfully, by the way. I have already created several libraries with it and had a lot of fun developing them).

@skirtles-code
Copy link
Contributor

From a documentation perspective, this has the potential to be a Cookbook entry. It might need to be multiple entries covering different aspects as I suspect it would be too much for a single entry.

#965 is related, though that only covers one specific part of the process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants