Export vuejs components to reuse
You can try to create a web component using VUE CLI 3 to use it later in a different code base. Just make sure your main.js
file looks like this
import Vue from 'vue';import wrap from '@vue/web-component-wrapper';import VueWebComponent from './components/VueWebComponent';const CustomElement = wrap(Vue, VueWebComponent);window.customElements.define('my-custom-element', CustomElement);
and build it using vue-cli-service build
with --target wc
You can read more precise instructions there:https://github.com/vuejs/vue-web-component-wrapperhttps://vuejsdevelopers.com/2018/05/21/vue-js-web-component/