// 创建 dist 文档
$ yarn build
查看部署文档
本地预览:
$ yarn global add serve
$ serve -s dist
推送 GitHub:
- 在
vue.config.js中设置正确的publicPath
// 手动推送更新
module.exports = {
publicPath: process.env.NODE_ENV === 'production'
? '/my-project/'
: '/'
}
- 在项目目录下,创建内容如下的
deploy.sh(可以适当地取消注释) 并运行它以进行部署:
#!/usr/bin/env sh
# 当发生错误时中止脚本
set -e
# 构建
npm run build
# cd 到构建输出的目录下
cd dist
# 部署到自定义域域名
# echo 'www.example.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 -
- 上传:
$ sh deploy.sh