For Vue create a new file in your project root named vue.config.js (Docs) and specify the publicPath (Docs).
NOTE if using a custom subdomain like http://project-name.your-domian.com
change publicPath to '/'
module.exports = {
publicPath: '/name-of-your-project/'
}
- Now commit and push your changes and run
npm run build
Note: if you don't commit your changes, you will lose them in the next command, so make sure you don't skip this step
Note: For the following commands, if you are using vue, just copy paste them, if you are using react replace dist with build.
-
npm run build
creates a directory with a production build of your app. In vue, that directory in named dist. -
git checkout --orphan gh-pages
-
npm run build
-
git --work-tree dist add --all
-
git --work-tree dist commit -m 'Deploy'
-
git push origin HEAD:gh-pages --force
-
rm -r dist
-
git checkout -f master
-
git branch -D gh-pages
-
Navigate to your github project and click 'Settings'
-
Scroll to find the section 'Github Pages' , select the gh-pages branch and click 'Save'