Xi Liu
Xi Liu

Reputation: 629

Update a react project that uses firebase hosting

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?

Upvotes: 3

Views: 6030

Answers (5)

Bilal Majeed
Bilal Majeed

Reputation: 1

It will work in 3 steps:

  1. npm run build
    
  2. firebase deploy
    
  3. Refresh the page

Run the above commands and then refresh the page.

Upvotes: 0

Aniket Kumar Sinha
Aniket Kumar Sinha

Reputation: 11

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

1st Command- npm run deploy

2nd Command- firebase deploy

It's done.

Upvotes: 1

Al-Amin
Al-Amin

Reputation: 99

You just have to run two commands.

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

Upvotes: 4

fadzb
fadzb

Reputation: 459

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

Upvotes: 0

Doug Stevenson
Doug Stevenson

Reputation: 317497

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

Upvotes: 0

Related Questions