Im trying to build a vue app for other vue project's to be use as a component for the app vue router. Here is my simple project structure for start,
|-- my-app
|-- lib
|-- my-app-component <-- folder copied from (my-app-component's dist)
|-- App.vue
|-- app.js
|-- package.json
|-- my-app-component
|-- dist
|-- App.vue
|-- app.js
|-- package.json
Here is the idea and steps that I'm trying to implement,
- build my-app-component as reusable component, the code at my-app-component->app.js is
import MyCustomElement from './App'
export {
MyCustomElement
}
- Copy the dist folder to my-app's lib folder, this is just temporary solution, will be further improve using Lerna and yarn workspaces once I manage to solve the current problem
- Import my-app-component from lib at my-app's lib, the code at my-app -> app.js is,
import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import MyAppComponent from '@lib/my-app-component'
const routes = [
{
name: 'MyAppComponent',
path: '/',
component: MyAppComponent
}
]
const router = new VueRouter({
routes
})
new Vue({
el: '#app',
router,
components: {
App
},
template: '<App/>'
})
Based on this steps, I can't seem to import the component successfully. Im building my component using vue-cli-service build command