Vue Cli 上傳 Github pages 路徑部屬問題│鼠年全馬鐵人挑戰 #18

CHEN
2 min readAug 5, 2020

--

Photo by Yancy Min on Unsplash

調整檔案路徑

在根目錄新創建 vue.config.js 檔案以及deploy.sh 檔案

1. 新增 vue.config.js 檔案

module.exports = {
publicPath: process.env.NODE_ENV === 'production'
? '/你的 repository 名稱/'
: '/'
}

2. 新增 deploy.sh 檔案

#!/usr/bin/env sh# abort on errorsset -e# buildnpm run build# navigate into the build output directorycd dist# if you are deploying to a custom domain# echo 'www.example.com' > CNAMEgit initgit add -Agit commit -m 'deploy'# if you are deploying to https://<USERNAME>.github.io# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master# if you are deploying to https://<USERNAME>.github.io/<REPO># git push -f git@github.com:<USERNAME>/<REPO>.git master:gh-pagesgit push -f https://github.com/<你的USERNAME>/<你的 repository>.git master:gh-pages# if you are deploying to https://<USERNAME>.github.io/<REPO># git push -f git@github.com:<USERNAME>/<REPO>.git master:gh-pages

在終端機輸入 (windows 使用 git bash )

sh deploy.sh

--

--

CHEN
CHEN

No responses yet