--- title: Vue env variable and github-page deploy tags: Vue note --- # Vue env variable and github-page deploy ## Vue set environment variable - vue-cli document https://cli.vuejs.org/guide/mode-and-env.html#modes VUE_APP_.. should start in VUE_APP for enviroment variable ## Vue deploy on github page - vue-cli document https://cli.vuejs.org/guide/deployment.html#github-pages - 將Vue專案部署至Github Pages (medium) https://medium.com/@dean34520/vue%E7%B3%BB%E5%88%97%E6%96%87-%E5%B0%87vue%E6%AA%94%E6%A1%88%E9%83%A8%E7%BD%B2%E8%87%B3github-334951cadede --- - should set repos to public - customize settting for those two file (<>) - delete # use you want in deploy.js --- > my-project/vue.config.js module.exports = { publicPath: process.env.NODE_ENV === 'production' ? '/<repo-name>/' : '/', }; --- > my-project/deploy.s #!/usr/bin/env sh # abort on errors set -e # build npm run build # navigate into the build output directory cd dist # if you are deploying to a custom domain # echo 'www.example.com' > CNAME git init git add -A git 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-pages cd - --- sh ./deploy.sh //run this in terminal to deploy