首页 > 其他 > 详细

Vue Cli 创建项目在 GitHub 部署 history 路由模式

时间:2020-04-13 09:07:04      阅读:70      评论:0      收藏:0      [点我收藏+]

1、修改打包路径

在 vue.config.js 中添加  publicPath  配置,其中 teambition-vue 是你项目的 github 名字。否则会找不到资源。

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

 

2、history 模式

GitHub 不支持单页面,使用 history 路由,会出现 404 ,所以把 index.html 的内容 copy 到 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

 

Vue Cli 创建项目在 GitHub 部署 history 路由模式

原文:https://www.cnblogs.com/wenruo/p/12688916.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!