VuePress 项目部署到 GitHub Pages
将 VuePress 项目部署到 GitHub Pages 大致需要以下几步
注: 需要 git 配置完毕,GitHub Pages 仓库已创建,才可进行以下几步
- 在项目根目录新建一个 deploy.sh 文件,文件内容如下 (请自行判断去掉高亮行的注释)
#!/usr/bin/env sh
# 确保脚本抛出遇到的错误
set -e
# 生成静态文件
npm run build
# 进入生成的文件夹( 进入VuePress打包后的文件夹根目录 )
cd public
# 如果是发布到自定义域名
# echo 'www.baidu.com(自定义域名)' > CNAME
git init
git add -A
git commit -m 'deploy'
# 如果发布到 https://<USERNAME>.github.io
# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master
# 如果发布到 https://<USERNAME>.github.io/<REPO>
# git push -f git@github.com:<USERNAME>/<REPO>.git master:gh-pages
cd -
- package.json 添加代码:
{
"scripts": {
"deploy": "deploy.sh"
}
}
- 部署到 GitHub Pages
npm run deploy
Powered by Waline v2.15.8