How to load local image to meta tag in html with webpack

Viewed 2911

I have a meta tag that should look like this

<meta property="og:image" content="https://mywebsite/img.jpg" />

I can't just set it to be './images/img.jpg'

I use webpack to compile my background images from my vue app so I can load this image somewhere in my template as background and then set it index.html in build folder. But it seems strange to do so and also webpack hashes images so they have different names after every build.

Is there a way out? Can I use HtmlWebpackPlugin maybe for this?

1 Answers

Ok, I think I solved the problem with this line of code in my index.html (not in build folder)

<meta property="og:image" content="<%= require('./images/img.jpg') %>" />
Related