0

I'm a newbie to both git and AWS.

I bought a domain using AWS and have connected it to a Github repository.

I pushed the app to repository without initiating an npm run build.

After realizing that the website was showing the readme.md instead of the index.html which is inside of the public folder (not that that's working either), I decided to try to run npm run build and push that to the github repository, thinking that maybe that could fix my issue. The problem I ran into was that /build is ignored inside .gitignore.

So I'm not sure if I should remove /build from .gitignore or find a work around, or something else I'm not aware of?

I would really appreciate some explanation from someone on that issue.

Thank you in advance.

T888
  • 69
  • 3
  • 14

2 Answers2

1

So, there are 2 different things that we must break down from this question . One related to git itself and other is to the app build.

.gitignore tells git which files (or patterns) it should ignore. It's usually used to avoid committing transient files from your working directory that aren't useful to other collaborators, such as compilation products, temporary files IDEs create, etc. It basically does keep track of the specified file or directory

More related to that can be found in here: http://git-scm.com/docs/gitignore.

Now, going to the original problem (which is building your app) github does have a CICD pipeline called github actions which essentially allows you to create a workflow based on a template that can help building your app. Therefore the build can be done when your is code is pushed, without have to send unnecessary files to your remote repository from your local npm run build. (You can find more related to this subject in this link: https://docs.github.com/en/actions/guides/building-and-testing-nodejs?learn=continuous_integration)

That doesn't necessary solves your issue with your App (because we are not discussing anything related to coding), but if your problem is just building the app that would be a starting point.

My other recommendation would be also to check more on how git/github actually works and how you can take advantage of these systems in the future to deploy/control your code.

Hopefully this can help!

Lucas Barbosa
  • 138
  • 1
  • 8
  • I appreciate the reply Lucas, but I'm kind of still wondering as to what I am supposed to be pushing to the repository, is it the build folder or the full app like I was doing before, or is there some sort of reference that I should include somewhere for github, or aws to read what is inside the build folder once I push it? – T888 Jul 10 '21 at 19:23
  • 1
    @T888: it's a personal choice thing (i.e., opinion). But, in my and many other people's opinion, pushing build artifacts, including the build directory, is a bad idea. – torek Jul 10 '21 at 20:41
  • @torek okay, so what's the workaround to make it work as intended then? meaning: how can I get github to read the index.html file inside of the public folder. Considering that that's what it needs to be reading if it's a react app. – T888 Jul 10 '21 at 20:48
  • So when you are saying that you are using AWS as a domain, are you using Amplify? Have you debug locally this app? tks – Lucas Barbosa Jul 10 '21 at 22:16
0

Found the answer to my question here. Thanks for the help guys.

Blank page after running build on create-react-app

T888
  • 69
  • 3
  • 14