如何使用 webpack 将本地图像加载到 html 中的元标记

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

我有一个应该如下所示的元标记

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

我不能只设置为 './images/img.jpg'

我使用 webpack 从我的 vue 应用程序编译我的背景图像,这样我就可以将此图像作为背景加载到我的模板中的某个位置,然后将其设置 index.html 在构建文件夹中。但这样做似乎很奇怪,而且 webpack 还会对图像进行哈希处理,因此它们在每次构建后都有不同的名称。

有出路吗?我可以为此使用 HtmlWebpackPlugin 吗?

好的,我想我在 index.html(不在构建文件夹)

中用这行代码解决了问题
<meta property="og:image" content="<%= require('./images/img.jpg') %>" />