Vue CliがGitHubに履歴ルーティングモードをデプロイするプロジェクトを作成します

1.パッケージパスを変更する

vPath.config.jsにpublicPath   構成を追加します。ここ   で、teambition-vueはプロジェクトのgithub名です。そうしないと、リソースが見つかりません。

module.exports = { 
    ... 
    // 部署到github 
    publicPath:process.env.NODE_ENV === 'production'?'/ teambition-vue': '/' 
};

 

2.履歴モード

GitHubは単一ページをサポートせず、履歴ルーティングを使用します。404があるため、index.htmlのコンテンツを404.htmlにコピーすると、この問題を独創的に解決できます。

 

3.導入

distディレクトリに入り、コンテンツをリモートにプッシュします

#!/ bin / bash 
npm run build 
cd。/ dist
 cp index.html 404 .html 
git init 
git remote add origin https:// github.com/G-lory/teambition-vue.git 
git add。
git commit -m ' deploy ' 
git checkout -b gh- pages 
git push -u origin gh-pages -f

 

おすすめ

転載: www.cnblogs.com/wenruo/p/12688916.html