问题
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