Vite+vue3 deploys static files to github
1. Create a new warehouse
- new warehouse
- Warehouse name: must be
[你的git用户名]或[仓库名称] + .github.io
, for example, your user name is YunZhonJun , unified to lowercase, such as ↓
Example 1 username+.github.io
yunzhonjun.github.io
Example 2 warehouse name +.github.io
colorspick.github.io
- renderings
- Press the create button in the lower left corner
-
After the creation is complete, open the newly created warehouse settings - settings
-
Open pages to see our static web address
2. Configure vite
vite configuration - the reference address has been clearly written https://vitejs.cn/vite3-cn/guide/static-deploy.html#github-pages
Document Personal Reference Configuration
import {
fileURLToPath, URL } from 'node:url'
import {
defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
base:'/colorspick.github.io/',
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})
3. Upload to github
- Uploaded folder opens Git-bash
- upload to warehouse
git init
git checkout -b main
git add -A
git commit -m '上传提示'
git push -f [email protected]:YunZhonJun/colorspick.github.io.git main
[email protected]:YunZhonJun/colorspick.github.io.git
is the warehouse address- main is the uploaded publishing source, such as: official website (reference address - https://docs.github.com/zh/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your- github-pages-site)
Static site demo - https://yunzhonjun.github.io/colorspick.github.io/
Note: The following content has nothing to do with deploying static sites above
Git error summary
Error errno 10054 reported when git push
- Enter the following command and then push
git config --global http.sslVerify "false"
- push
git add .
git commit -m "更新文档+修复bug"
git push origin master
failed to push some refs to || non-fast-forward
- Error failed to push some refs to or ↓
- non-fast-forward
Note:
Note:
Note:
Do not use the downstream commands indiscriminately. Please back up your own project before using it. It may cause garbled characters, error reports, problems, and failure to run the project.
Mainly execute the following command first and then push
git pull origin master --allow-unrelated-histories
example
git pull origin master --allow-unrelated-histories
git add .
git commit -m "更新文档+修复bug"
git push origin master