When using these to deploy to github :
git commit -am "Save local changes"
git checkout -B gh-pages
git add -f build
git commit -am "Rebuild website"
git filter-branch -f --prune-empty --subdirectory-filter build
git push -f origin gh-pages
git checkout -
Github loses the custom domain setting
Note : I think it's due to the -B
option in git checkout -B gh-pages
.
We're likely going to change the GitHub deployment instructions to use the simpler docs
folder in master
branch approach (#520).
The new set of commands to deploy will be basically:
npm run build
mv build docs
git add docs
git commit -m "Rebuild website"
git push origin master
I think this issue will be fixed by that change?
@fson it think so. thanks.
gh-pages in combination with following script seems to work pretty well for me:
"deploy": "npm run build && gh-pages -d build"
this pushes the build folder to the gh-pages
branch. Basically turning that set of comands into a one liner.
Edit:
Just saw the discussion under https://github.com/facebookincubator/create-react-app/pull/520. gh-pages
could be the solution they were looking for.
gh-pages
looks like what we want indeed, so we just need to document the command in Create React App and test that it works. @Janpot would you be interested in making a pull request?
Also gh-pages
will overwrite the CNAME
file, because it just always pushes everything from the build folder to the gh-pages
branch.
A simple workaround for this problem is to add a CNAME
file with the custom domain inside the public
folder in your project and it will be copied to the build and deployed.
I believe this is no longer an issue. I thought I was coming across it, but the problem was that I had not re-run npm run build
since adding the CNAME
file to public/
.
Using @Janpot's recommended deploy
script:
"deploy": "npm run build && gh-pages -d build"
rather than the readme's recommendation
"deploy": "gh-pages -d build"
would have saved me 20 minutes of debugging the problem.
¯\_(ツ)_/¯
@dsernst yeah, not sure why I didn't put my original script. And in retrospect I regret my decision.
Most helpful comment
Also
gh-pages
will overwrite theCNAME
file, because it just always pushes everything from the build folder to thegh-pages
branch.A simple workaround for this problem is to add a
CNAME
file with the custom domain inside thepublic
folder in your project and it will be copied to the build and deployed.