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 the dist folder after the build?
If I import from path-to-myLib/src/component.vue, everything is fine! But the code below does not work:
// undefined
import { component } from 'path-to-myLib/dist/myLib.umd.js'
// undefined
import myComponent'path-to-myLib/dist/myLib.umd.js'
// result: https://i.sstatic.net/xHSzL.png
import * as myComponent'path-to-myLib/dist/myLib.umd.js'
I cannot understand what the problem is.
you must add main to your package.json like this "main":"path-to-myLib/dist/myLib.umd.js", pointing to the generated umd file and then use import {component} from 'library' and use in library library name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With