How to make create-react-app auto build?

后端 未结 5 1897
傲寒
傲寒 2020-12-14 09:21

I have been using create react app for a while. \'npm start\' or \'yarn start\' autoreloads works fine by itself but now I have an another problem. Currently I run the app o

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 09:50

    While this doesn’t really answer your question, you shouldn’t be using npm run build in development. Not only the rebuilds are slow, but it also skips important React warnings for performance and size, so you’ll end up scratching your head more and getting a lot less details in the warnings.

    If you just need to do API requests with Express, use the proxy feature which lets you proxy API requests from npm start to your server. There is also a tutorial with a matching repository demonstrating how to do that.

    In production, of course, you should use the build produced by npm run build. But you would only need to run it before deployment.

提交回复
热议问题