Sunday, 8 September 2019

Post 71: Publish gitHub page with VueJS + Vue cli


  1. Create a project on gitHub
  2. clone that gitHub project on your computer with `git clone ...`
  3. in your terminal, go to that project with `cd .....`
  4. create a vue project in that folder with `vue create .`
  5. install all dependencies `yarn install`
  6. in the `.gitignore` file comment out the folder `/dist` (we will later publish our vueJS page in that `dist` folder and push it on gitHub)
  7. create a new branch with `git co -b gh-pages`
  8. create a new file `vue.config.js` with `touch vue.config.js`
  9. in that file write: module.exports = { publicPath: ‘<my-project>’ }
  10. modify the changes you want to make
  11. test your changes with `yarn serve`
  12. if you are satisfied we can build for production with `yarn build`
  13. add the changes you want to push: `git add dist && git commit -m "Initial dist subtree commit`
  14. push only the dist folder to your gh-branch on gitHub: `git subtree push --prefix dist origin gh-pages`. This part is very important. If you push everything into gitHub, then nothing will be displayed. The trick is to only push the `dist` folder on to gitHub. In order not to lose any changes, I would commit and push everything to `master` and on the branch `gh-pages`, I'd only push the `dist` changes  
  15. go to gitHub and then to the settings
  16. in the section gitHub pages you should see a link where your vueJS can be reached. Click on that and you should see the same page you see earlier with `yarn serve` 

No comments:

Post a Comment

Tweet