- Set the publicPath to be deployed in vue.config.js
module.exports = { publicPath: process.env.NODE_ENV === 'production' ? '/ project name -website/' : '/'}Copy the code
- The first yarn build
yarn build
- Click in to see the document
- Follow the documentation and run
yarn global add serve
serve -s dist
-
Check that the packing is ok
-
Go to Github to create a new repository (the first time to create a repository for all the code)
-
Then perform
Git remote add Origin [email protected]: username/project name.git
git push -u origin master
-
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)
-
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
- Finally the command line is executed
sh deploy.sh
-
Refresh the new warehouse page for the second time, and the deployment is complete
-
The project preview link is here