A short number of steps to get a react app build, tested and then hosted on Github Pages using Travis.
These steps assume you have NodeJS installed. You also need to install create-react-app. If you dont have this enter :
npm install -g create-react-app
By default, React expects the page to be served from the root of a domain. However, if the page is being served on GitHub Pages, it won't be there, so you need to tell React to use relative paths.
Edit your package.json
as such:
{
"name": "...",
"version": "...",
"more fields": "...",
"homepage": "."
}
Travis needs to be setup to start builds when we push to the master.
In order to run and build our content we dont need to provide travis with much other than a config file. But in order to give travis access to the repo to push builds we will need to generate a personal access token.
To set up github pages auto builds we need to give travis a personal access token. This can be gotten from here.
We we have the personal access token we need to set it up as an enviroment variable in Travis itself like so :
Inspired by this article
Thanks goes to these wonderful people (emoji key):
Ryan Gordon 💻 📖 |
Zach Deibert 📖 |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!