How to run build version using create-react-app?

前端 未结 3 1354
一个人的身影
一个人的身影 2021-02-05 00:38

So, I developed a small React application using create-react-app. (I have always made applications from scratch.)

Then, after I was kind of happy with it, I decided to r

3条回答
  •  粉色の甜心
    2021-02-05 01:42

    When you run npm run build your console should actually say something like the following

    The build folder is ready to be deployed.
    You may serve it with a static server:
    
    npm install -g serve
    serve -s build
    

    The build script is building your entire app into the build folder, ready to be statically served. However actually serving it require some kind of static file server, like the the one they propose.

    After running the command serve -s build you can access your production build at localhost (on the specified port).

    You can of course run whatever static file server you like, I usually use express for this, however serve seems like the easiest option to just serve your statics files with a single command.

提交回复
热议问题