After installing these two packages as we need them for deploy:
npm i now -g
npm i serve
follow these steps:
In package.json
change the script part to this:
"scripts": {
...
"start": "serve --single ./build",
"dev": "react-scripts start",
"build": "react-scripts build",
"now-build": "npm run build && mv build dist",
...
},
You also need to add
serve
package as we need it for start script.
Then add a new file now.json
next to the root directory of your application.
{
"version": 2,
"name": "name-of-your-application",
"builds": [{ "src": "package.json", "use": "@now/static-build" }],
"routes": [
{ "src": "^/static/(.*)", "dest": "/static/$1" },
{ "src": "^/images/(.*)", "dest": "/images/$1" },
{ "src": ".*", "dest": "/index.html" }
]
}
Finally run the now
command and DONE!
More info Here
Thank you! This got Now working for me.