手动部署
参考文档yarn build 打包
使用serve预览打包后的项目yarn global add serveserve -s build
在github新建一个仓库,将build文件夹上传到github
cd buildgit initgit add .git commit -m "init"git remote add origin 仓库地址git push origin
设置github pages, 发现请求的路径有问题
在package.json中添加相对路径,重新打包上传github
"homepage": "./",
自动部署
在scripts目录新建deploy.sh文件,输入下列内容
#!/usr/bin/env bashyarn build &&cd build &&git init &&git add . &&git commit -m "deploy" &&git remote add origin 仓库地址 &&git push -u origin master -fcd -
如果是linux系统需执行命令chmod +x scripts/deploy.sh
运行命令sh scripts/deploy.sh执行脚本
或者在package.json的scripts中添加命令
"scripts": {"deploy": "sh scripts/deploy.sh"},
yarn deploy执行命令
部署到码云只需要修改仓库地址,码云需要手动更新git pages
