From f8cc3b7faf95bd938debc92b166d7293e729d4db Mon Sep 17 00:00:00 2001 From: Andy Eskridge Date: Tue, 30 Aug 2016 23:02:53 -0500 Subject: [PATCH 1/3] Add new github docs folder hosting option --- scripts/build.js | 12 +++++++++++- template/README.md | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/scripts/build.js b/scripts/build.js index b02d8dc3200..b7351676175 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -128,7 +128,7 @@ function build(previousSizeMap) { console.log('You can control this with the ' + chalk.green('homepage') + ' field in your ' + chalk.cyan('package.json') + '.'); console.log(); console.log('The ' + chalk.cyan('build') + ' folder is ready to be deployed.'); - console.log('To publish it at ' + chalk.green(homepagePath) + ', run:'); + console.log('To publish it at ' + chalk.green(homepagePath) + ' using the gh-pages branch, run:'); console.log(); console.log(' ' + chalk.cyan('git') + ' commit -am ' + chalk.yellow('"Save local changes"')); console.log(' ' + chalk.cyan('git') + ' checkout -B gh-pages'); @@ -138,6 +138,16 @@ function build(previousSizeMap) { console.log(' ' + chalk.cyan('git') + ' push -f origin gh-pages'); console.log(' ' + chalk.cyan('git') + ' checkout -'); console.log(); + console.log('To publish it at ' + chalk.green(homepagePath) + ' using the docs/ folder, run:'); + console.log(); + console.log(' ' + chalk.cyan('git') + ' commit -am ' + chalk.yellow('"Save local changes"')); + console.log(' ' + chalk.cyan('rm') + ' -r docs/'); + console.log(' ' + chalk.cyan('mv') + ' build/ docs/'); + console.log(' ' + chalk.cyan('git') + ' add -f docs'); + console.log(' ' + chalk.cyan('git') + ' commit -am ' + chalk.yellow('"Rebuild website"')); + console.log(' ' + chalk.cyan('git') + ' filter-branch -f --prune-empty --subdirectory-filter docs'); + console.log(' ' + chalk.cyan('git') + ' push -f origin master'); + console.log(); } else if (publicPath !== '/') { // "homepage": "http://mywebsite.com/project" console.log('The project was built assuming it is hosted at ' + chalk.green(publicPath) + '.'); diff --git a/template/README.md b/template/README.md index 4dd68fcd621..4bc7b688639 100644 --- a/template/README.md +++ b/template/README.md @@ -567,6 +567,20 @@ git push -f origin gh-pages git checkout - ``` +To host your app using the `/docs` folder you just need to move the `build` folder to a new `docs` folder, check in the new `docs` folder and set the GitHub Pages Source to the `master branch /docs folder` setting. [Read More](https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/#publishing-your-github-pages-site-from-a-docs-folder-on-your-master-branch) here about setting up the GitHub settings. + +You can use the following sequence of commands to clear out the old docs folder, move the build to the docs folder, and then check it in to the master branch: + +```sh +git commit -am "Save local changes" +rm -r docs/ +mv build/ docs/ +git add -f docs +git commit -am "Rebuild website" +git filter-branch -f --prune-empty --subdirectory-filter docs +git push -f origin master +``` + You may copy and paste them, or put them into a custom shell script. You may also customize them for another hosting provider. Note that GitHub Pages doesn't support routers that use the HTML5 `pushState` history API under the hood (for example, React Router using `browserHistory`). This is because when there is a fresh page load for a url like `http://user.github.io/todomvc/todos/42`, where `/todos/42` is a frontend route, the GitHub Pages server returns 404 because it knows nothing of `/todos/42`. If you want to add a router to a project hosted on GitHub Pages, here are a couple of solutions: From 50e8f77a80e636016114a1323855fc605c8438f0 Mon Sep 17 00:00:00 2001 From: Andy Eskridge Date: Thu, 8 Sep 2016 18:13:25 -0500 Subject: [PATCH 2/3] remove old github pages documentation --- scripts/build.js | 17 +++-------------- template/README.md | 21 ++++----------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index b7351676175..6ecef296c72 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -128,25 +128,14 @@ function build(previousSizeMap) { console.log('You can control this with the ' + chalk.green('homepage') + ' field in your ' + chalk.cyan('package.json') + '.'); console.log(); console.log('The ' + chalk.cyan('build') + ' folder is ready to be deployed.'); - console.log('To publish it at ' + chalk.green(homepagePath) + ' using the gh-pages branch, run:'); - console.log(); - console.log(' ' + chalk.cyan('git') + ' commit -am ' + chalk.yellow('"Save local changes"')); - console.log(' ' + chalk.cyan('git') + ' checkout -B gh-pages'); - console.log(' ' + chalk.cyan('git') + ' add -f build'); - console.log(' ' + chalk.cyan('git') + ' commit -am ' + chalk.yellow('"Rebuild website"')); - console.log(' ' + chalk.cyan('git') + ' filter-branch -f --prune-empty --subdirectory-filter build'); - console.log(' ' + chalk.cyan('git') + ' push -f origin gh-pages'); - console.log(' ' + chalk.cyan('git') + ' checkout -'); - console.log(); console.log('To publish it at ' + chalk.green(homepagePath) + ' using the docs/ folder, run:'); console.log(); console.log(' ' + chalk.cyan('git') + ' commit -am ' + chalk.yellow('"Save local changes"')); - console.log(' ' + chalk.cyan('rm') + ' -r docs/'); + console.log(' ' + chalk.cyan('rm') + ' -rf docs/'); console.log(' ' + chalk.cyan('mv') + ' build/ docs/'); - console.log(' ' + chalk.cyan('git') + ' add -f docs'); + console.log(' ' + chalk.cyan('git') + ' add docs'); console.log(' ' + chalk.cyan('git') + ' commit -am ' + chalk.yellow('"Rebuild website"')); - console.log(' ' + chalk.cyan('git') + ' filter-branch -f --prune-empty --subdirectory-filter docs'); - console.log(' ' + chalk.cyan('git') + ' push -f origin master'); + console.log(' ' + chalk.cyan('git') + ' push origin master'); console.log(); } else if (publicPath !== '/') { // "homepage": "http://mywebsite.com/project" diff --git a/template/README.md b/template/README.md index 4bc7b688639..8161a62d3a0 100644 --- a/template/README.md +++ b/template/README.md @@ -555,30 +555,17 @@ Open your `package.json` and add a `homepage` field: **The above step is important!** Create React App uses the `homepage` field to determine the root URL in the built HTML file. -Now, whenever you run `npm run build`, you will see a cheat sheet with a sequence of commands to deploy to GitHub pages: - -```sh -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 - -``` - -To host your app using the `/docs` folder you just need to move the `build` folder to a new `docs` folder, check in the new `docs` folder and set the GitHub Pages Source to the `master branch /docs folder` setting. [Read More](https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/#publishing-your-github-pages-site-from-a-docs-folder-on-your-master-branch) here about setting up the GitHub settings. +To host your app using the `/docs` folder you just need to move the `build` folder to a new `docs` folder, check in the new `docs` folder and set the GitHub Pages Source to the `master branch /docs folder` setting. [Read more here](https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/#publishing-your-github-pages-site-from-a-docs-folder-on-your-master-branch) about setting up the GitHub settings. You can use the following sequence of commands to clear out the old docs folder, move the build to the docs folder, and then check it in to the master branch: ```sh git commit -am "Save local changes" -rm -r docs/ +rm -rf docs/ mv build/ docs/ -git add -f docs +git add docs git commit -am "Rebuild website" -git filter-branch -f --prune-empty --subdirectory-filter docs -git push -f origin master +git push origin master ``` You may copy and paste them, or put them into a custom shell script. You may also customize them for another hosting provider. From abebfcadb4f4f4b2f057eb1a5237e1a583501b6c Mon Sep 17 00:00:00 2001 From: Andy Eskridge Date: Sun, 11 Sep 2016 22:40:20 -0500 Subject: [PATCH 3/3] update git add command to include -A --- scripts/build.js | 2 +- template/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index 391da669868..9e7a81da94a 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -135,7 +135,7 @@ function build(previousSizeMap) { console.log(' ' + chalk.cyan('git') + ' commit -am ' + chalk.yellow('"Save local changes"')); console.log(' ' + chalk.cyan('rm') + ' -rf docs/'); console.log(' ' + chalk.cyan('mv') + ' build/ docs/'); - console.log(' ' + chalk.cyan('git') + ' add docs'); + console.log(' ' + chalk.cyan('git') + ' add docs -A'); console.log(' ' + chalk.cyan('git') + ' commit -am ' + chalk.yellow('"Rebuild website"')); console.log(' ' + chalk.cyan('git') + ' push origin master'); console.log(); diff --git a/template/README.md b/template/README.md index bb6b4412138..dd522659fa5 100644 --- a/template/README.md +++ b/template/README.md @@ -858,7 +858,7 @@ You can use the following sequence of commands to clear out the old docs folder, git commit -am "Save local changes" rm -rf docs/ mv build/ docs/ -git add docs +git add docs -A git commit -am "Rebuild website" git push origin master ```