问题 :
\n这是我使用 React/Vite 应用程序运行构建时发生的情况:
\nvite 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`\nRun Code Online (Sandbox Code Playgroud)\n预期结果:构建成功。
\n在开发模式下一切正常。
\n我尝试了什么:
\n这里有一个解决方案,建议将“/”添加到index.html中脚本的路径中,但在我的代码中已经是这种情况,并且它不起作用。我仍然尝试不使用“/”,以防万一。
\n我的一些代码:
\n在index.html中:
\n<script type="module" src="/src/bootstrap.tsx"></script>\nRun Code Online (Sandbox Code Playgroud)\n在 vite.config.ts 中:
\nimport { defineConfig, loadEnv } from \'vite\';\nimport react from …Run Code Online (Sandbox Code Playgroud)