【发布时间】:2023-02-24 05:42:54
【问题描述】:
我有这个项目结构:
> Assets
> node_modules
> public
> src
.gitignore
.index.html
package-lock.json
package.json
vite.config.js
在我的索引 html 中,我有指向 ./src/main.jsx 的脚本
现在的事情是我想将我的 index.html 文件移动到 public 文件夹中,我将我的脚本从 index.html 文件更改为指向../src/main.jsx,我添加了根键以指向 vite 中的“public” .config.js 文件,但当我运行 npm run dev 时,我得到的只是一个空白页面,浏览器控制台中出现此错误消息:GET http://localhost:5173/src/main.jsx net::ERR_ABORTED 404 (Not Found ).有什么想法吗?
【问题讨论】:
-
你为什么要这样做?通常它会在 src 中,并且在生产构建中将在 dist 中生成一个 index.html,您将使用它在 prod 中提供服务。