部署

按照官方文档的指示 检查dist是否打包正确

1
2
3
4
5
yarn build 

yarn global add serve  # 全局安装serve

serve -s dist

部署到gitHub my-project===我的仓库名

1
2
3
4
5
module.exports = {
  publicPath: process.env.NODE_ENV === 'production'
    ? '/my-project/'
    : '/'
}

创建deploy.sh

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env sh

# 当发生错误时中止脚本
set -e

# 构建
yarn 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:Gaocarri/Money-website.git master:gh-pages

cd -

部署 新建一个仓库

1
sh deploy.sh