Why do I need a server with create-react-app

﹥>﹥吖頭↗ 提交于 2021-02-19 03:05:02

问题


I recently created a website with create-react-app. Since this is not a web app, why do I need a server to see it? I tried to open the index file in build folder but it doesn't work unless I'm serving it from a server.


回答1:


You can set the homepage root url in the package.json file e.g.

{
   ...,
   "homepage":"file:///<path to build directory"
}

npm run build

This will now find the static content in the build directory from the file system without a server.



来源:https://stackoverflow.com/questions/44530861/why-do-i-need-a-server-with-create-react-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!