img src 路径不会在 vite 构建上更新

发布于 2025-01-20 17:45:15 字数 945 浏览 1 评论 0原文

我正在尝试使用 Vite 构建一个多页面应用程序。但是,当我运行 vite build 脚本时,它会在 dist 中构建我的应用程序,但不会更新我的 html 图像源属性。这就是我的 html 文件的一行的样子,并且它在构建输出(在 dist 文件夹中)中保持不变。

<img src="../../assets/ac.svg"><>

我看到我的 ac.svg 就在那里,因为它已被重新哈希并移入 dist>assets

在此处输入图像描述

但我的路径永远不会更新:

在此处输入图像描述

我的其他路径正常更新为新的哈希资产:

在此处输入图像描述

我已尝试将资产文件夹更改为“public”,但路径仍然没有更新我的 html 文件。

另一件不会改变其 URL 的东西是 favicon(来自 dist 构建 html 文件):

<link rel="shortcut icon" href="../../assets/favicon.ico" type="image/x-icon">

I'm trying to build a multi-page application with Vite. however, when I run a vite build script, it builds out my app in dist, but does not update my html's image source attribute. This is what one line of my html file looks like, and it remains the same in the build output (in dist folder).

<img src="../../assets/ac.svg"><>

I see that my ac.svg is in there since it's been rehashed and moved in dist>assets:

enter image description here

But my path never updates:

enter image description here

My other paths update normally to the new hashed asset:

enter image description here

I've tried changing my assets folder to be named 'public' but the path still does not update in my html files.

Another thing that doesn't change its URL is the favicon (from dist build html file):

<link rel="shortcut icon" href="../../assets/favicon.ico" type="image/x-icon">

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文