解決Vue-CLI v3.0 專案上傳到gh-pages 路徑錯誤的問題

Raymond Yeh
Sep 1, 2018 · 2 min read

Vue-Cli v3.0很新很新,但也很快踩到一個坑,我嘗試寫一個vue-cli的專案然後上傳到Github上的gh-pages,但是發現一片空白,打開開發者模式看後發現檔案都被多加上了一層/js/ 或是/css/,嘗試改config的輸出位置,卻發現3.0把config藏起來了,這也是那個坑的所在。


首先看正確的路經應該如下,不應該出現/js/app 或是/css/app的情況

想要修改隱藏起來的config參考官方文件,可以下vue config來修改或查看config

發現cli剛建好的專案下幾乎什麼都沒有,必須自己寫一隻vue.config.js設定需要的配置。

放置位置需與package.json同層級,才能被webpack包進去使用


如此一來便能解決build完後引用路徑錯誤的問題。

至於上傳到gh-pages的部分,可以參考這篇文章,在此就不多贅述了。


2019 UPDATED

baseUrl 已經被棄用,請改用publicPath


Raymond Yeh

Written by

A front end developer who is hard working but useless in the world.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade