/manual-deploy

No downtime while React app builds on the server.

Manual npm script deploy over ssh

No downtime while React app builds on the server.

Bypass "500 Internal Server Error" screen message.

Prerequisites

Install npm package copyfiles as a dev dependency. https://www.npmjs.com/package/copyfiles

npm -i copyfiles --save-dev

Process

In package.json add 2 new scripts:

"prebuild": "BUILD_PATH='./prebuild' react-scripts build"

This will change Build path to ./prebuild (supported with react-scripts >= 4.0.2).

"copy": "copyfiles -u 1 'prebuild/*/' build && rm -rf prebuild"

This will copy everything from temporary build folder ./prebuild to ./build and remove the temporary folder as soon as the content copying is done.

Change your main "build" script to run the previously added scripts:

"build": "npm run prebuild && npm run copy"

Run npm run build

Until all the content from ./prebuild is copied into ./build, old react app version from ./build folder will remain online.