I am trying to publish a Vue library to npmjs and the library has a few images in it.
I publish the app to NPM, Import it into my main app and everything seems to function as expected, but the path to the images of the library are wrong and I can't seem to fix the link to them (I can see that the images are located in the node_modules folder of my library. Shouldn't my main vue app extract the images from the library when I run npm run serve
?)
I tried to make a simplified demo of this problem to try to understand it.
In my Library, I created a really basic component
<div class="hello">
<h1>{{ msg }}</h1>
<img alt="Vue logo" src="@/assets/xlogo.png" />
<img alt="Vue logo" :src="require('../assets/xlogo.png')" />
<p>This is a paragraph.</p>
</div>
I then build the library with the following node command. (the command is in the package.json and I run it via npm run build:lib
)
vue-cli-service build --target lib --name tmp ./src/components/index.vue
Then I try to import that library into my main vue app
import HelloWorld from '../../tmp/dist/tmp.umd.js'
<template>
<HelloWorld msg="Welcome to Your Vue.js App.."/>
</template>
I created a git repo to demonstrate this. So How would I go about changing it so the images are included in the library? Any pointers would be much appreciated as I have spent hours trying to figure this out on my own already :(