[英]how to run a different html file instead of index.html when webpack server runs?
[英]How to run React application by clicking index.html file without any local server
当我启动“npm start”时,我使用 create-react-app 创建了反应应用程序,它在浏览器中使用 localhost:3000 运行,这很好。 但是,当我从项目文件夹中单击 index.html 时,它显示空白页。 你能给我建议如何使用 index.html 文件运行反应应用程序的解决方案吗
将"homepage": ".",
添加到package.json
文件的顶部。 然后用yarn build
或npm build
。 Go build/
文件夹并双击index.html
。
编辑:
通过index.html打开应用需要
"homepage": "."
inpackage.json
because without it Webpack tries to load the static files from the root the file system rather than build directory. 参考
您可以运行npm run build
,然后运行 go 到“build”文件夹,工作 index.html 将位于该文件夹。 项目文件夹中的 index.html 不是为生产/独立使用而构建的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.