diff --git a/scripts/build.js b/scripts/build.js index e60b554466..9e7a81da94 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -130,15 +130,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) + ', run:'); + 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('git') + ' checkout -B gh-pages'); - console.log(' ' + chalk.cyan('git') + ' add -f build'); + console.log(' ' + chalk.cyan('rm') + ' -rf docs/'); + console.log(' ' + chalk.cyan('mv') + ' build/ 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') + ' 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(' ' + 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 05ef2b43aa..dd522659fa 100644 --- a/template/README.md +++ b/template/README.md @@ -850,16 +850,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: +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" -git checkout -B gh-pages -git add -f build +rm -rf docs/ +mv build/ docs/ +git add docs -A git commit -am "Rebuild website" -git filter-branch -f --prune-empty --subdirectory-filter build -git push -f origin gh-pages -git checkout - +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.