1. Set the publicPath to be deployed in vue.config.js
module.exports = { publicPath: process.env.NODE_ENV === 'production' ? '/ project name -website/' : '/'}Copy the code
  1. The first yarn build

yarn build

  1. Click in to see the document

  1. Follow the documentation and run

yarn global add serve

serve -s dist

  1. Check that the packing is ok

  2. Go to Github to create a new repository (the first time to create a repository for all the code)

  3. Then perform

Git remote add Origin [email protected]: username/project name.git

git push -u origin master

  1. Go to Github and create a new repository with the same name as the publicPath in step 1, for example: project name-website (second new repository for deployment)

  2. Create a new deploy.sh file (for deployment) in the project root directory and write the following code

#! /usr/bin/env sh # Stop script when an error occurs set -e # build YARN build # CD dist # deploy to custom domain # echo 'www.example.com' > CNAME Git git add -a git commit -m 'deploy' # https://<USERNAME>.github [email protected]: USERNAME/project name git master # deploy to https://<USERNAME>.github. IO /<REPO [email protected]: username/project name -website. Git master:gh-pages CD -Copy the code
  1. Finally the command line is executed

sh deploy.sh

  1. Refresh the new warehouse page for the second time, and the deployment is complete

  2. The project preview link is here