1
votes

I'm using vue-cli for build my lib with this command: "build": "vue-cli-service build --target lib --name myLib ./src/component.vue",

How can i import my component from dist folder after build?

I'm tried

 // undefined
 import { component } from '../../myLib/dist/myLib.umd.js' 
 // undefined
 import myComponent'../../myLib/dist/myLib.umd.js' 
 // see picture below
 import * as myComponent'../../myLib/dist/myLib.umd.js'

Last variant gives me this:

enter image description here

My component.vue is valid(too large to show)

1

1 Answers

1
votes

Hi I pasted the dist directory under node_modules/myLib and then used my package with import MyComponent from 'myLib'

(alternatively if npm complains about not finding your lib you can publish it on npm, if it is not an issue to have it as public package).