Update a react project that uses firebase hosting

Viewed 3664

I used firebase hosting to serve my react website. If I want to make changes to my website, do I need to type npm run build every time after I change my local files so that a new build folder overlaps the old one and then type firebase deploy?

4 Answers

You just have to run two commands.

  1. npm run build
  2. firebase deploy that's it. Then refresh your web page.

Do all your the changes in your React app. And run

1st Command- npm run deploy

2nd Command- firebase deploy

It's done.

Yes, that is required. If you don't generate and deploy new code and assets, nothing will change on your site.

You don't need to deploy firebase to cloud hosting every time you want to test it locally. You can use firebase serve --only hosting to deploy on localhost.

npm run build depends entirely on your package.json, I'm not sure what your scripts look like.

However, I think your actually asking how to achieve hot reloading of your client during development. I don't remember ever having an issue achieving this using Create-React-App https://reactjs.org/docs/create-a-new-react-app.html#create-react-app which uses webpack.

The user guide details how to use npm start which should enforce hot-reloading: https://create-react-app.dev/docs/available-scripts#npm-start

Related