小编Car*_*e.S的帖子

Rollup 无法解析从“index.html”导入“src/bootstrap.tsx”

问题 :

\n

这是我使用 React/Vite 应用程序运行构建时发生的情况:

\n
vite v2.9.6 building for production...\n\xe2\x9c\x93 1 modules transformed.\n\nERROR  [vite]: Rollup failed to resolve import "src/bootstrap.tsx" from "index.html".\nThis is most likely unintended because it can break your application at runtime.\nIf you do want to externalize this module explicitly add it to        \n`build.rollupOptions.external`\n
Run Code Online (Sandbox Code Playgroud)\n

预期结果:构建成功。

\n

在开发模式下一切正常。

\n

我尝试了什么:

\n

这里有一个解决方案,建议将“/”添加到index.html中脚本的路径中,但在我的代码中已经是这种情况,并且它不起作用。我仍然尝试不使用“/”,以防万一。

\n

我的一些代码:

\n

在index.html中:

\n
<script type="module" src="/src/bootstrap.tsx"></script>\n
Run Code Online (Sandbox Code Playgroud)\n

在 vite.config.ts 中:

\n
import { defineConfig, loadEnv } from \'vite\';\nimport react from …
Run Code Online (Sandbox Code Playgroud)

rollup build vite

6
推荐指数
0
解决办法
4445
查看次数

标签 统计

build ×1

rollup ×1

vite ×1