gh-pages
npm install gh-pages --save-dev
vue.config.js
module.exports = { publicPath: process.env.NODE_ENV === 'production' ? '/<你的GitHub儲存庫名稱>/' // 替換成你的儲存庫名稱 : '/dist' };
package.json
"scripts": { "build": "vue-cli-service build", "deploy": "npm run build && gh-pages -d dist" }
git init git add . git commit -m "Initial commit" git branch -M main git remote add origin https://github.com/<你的GitHub使用者名稱>/<儲存庫名稱>.git git push -u origin main
npm run build
npm run deploy
npm run deploy -- --no-verify
如果遇到突然無法部屬至Github可以這樣做
<branch-name>
git checkout <branch-name>
git rm -r --cached .
git commit -m "清除遠端檔案"
git push origin <branch-name>
git rm -r *
git commit -m "Clear all files in the branch"
VueCli打包後部屬至Github
一、第一步-建置與安裝套件
gh-pages
套件二、第二步-修改設定
vue.config.js
package.json
編輯 package.json,在 scripts 中新增以下指令:
三、第三步-部屬專案
四、補充
如果遇到突然無法部屬至Github可以這樣做
<branch-name>
分支名稱如:gh-pages