A
A
Andrew2021-07-07 16:51:09
Vue.js
Andrew, 2021-07-07 16:51:09

What is the best way to reuse one Vue component between multiple projects?

In one of the projects, a visual editor was written. I would like to reuse it in different projects, but a simple copy-paste seems not very convenient.

I thought about wrapping it in a private npm package, but I still don’t understand how convenient it will be. The task is as follows: there is a common functionality that needs to be improved and bugs that also need to be fixed, regardless of the project. However, each project needs its own visual features and customizations, which are conveniently done through copy-paste - just corrected the necessary component and that's it, while if it is an npm package, you will need to think through some kind of interface for customization.

In general, if anyone has encountered a similar problem, I will be glad to hear your solutions.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-07-07
@Aetae

A separate private package with components is, of course, in vue-cli it is possible to build a library out of the box.
And so it all comes down to architecture. Just (*plays with eyebrows*) think over your solution so that it is convenient to customize it. There is no universal solution. The main thing is to remember all the features of Vue - mixins (or extends), slots, props, events, provide \ inject and do it with them in mind.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question