Home > front end >  Which is the correct / better way to publish and maintain (update) a React JS App?
Which is the correct / better way to publish and maintain (update) a React JS App?

Time:10-11

Beginning React js development, I built the first project. I noticed the folder called build, then I uploaded that folder into the webserver and the app build was successful.

My question is: Which is the better practice to do this, without need to upload that folder every time I update the code?

Before React, I developed in PHP and update the production app was simple like create a Github Repo, link server with Git, and every time that I had update code, only needed to Push changes.

With React I don't want to upload this folder manually. I think that to upload all development code isn't a good practice. And creating a Github Repo only for the build folder is not possible (Please correct me, you can`t have a repository inside another repository).

Concluding the question: What is the way you use considering that you can do it easily and quickly?

CodePudding user response:

I would recommend doing something similar to what you did in PHP. You can create a Github repo for your project, and link it to a hosting platform such as Netlify or Vercel. There are many other options, these are just the first two that came to mind.

If you already have a web server for hosting, and you don't want to use one of these hosting platforms, you could use something like Github Actions to trigger a build on Github's server and then deploy it to your server. Maybe something similar to this example. But instead of deploying to Github pages, just deploy it to your server.

Before pushing to Github, I would recommend creating a .gitignore file and adding your build folder, so that your local build won't get pushed up to Github.

CodePudding user response:

Use services like vercel or netlify. You just need to push your code to github or gitlab whatever you prefer or use, You don't need to npm build. Just go to these website select your repo and they will build their own.

  • Related