vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.48k stars 1.86k forks source link

`_assets` folder not accessible when deploying to GitHub Page #124

Closed xiaoxian521 closed 3 years ago

xiaoxian521 commented 3 years ago

Describe the bug Package and deploy to GitHub, no resource package 404 error found

To Reproduce Steps to reproduce the behavior: Package and deploy to GitHub, no resource package 404 error found

Expected behavior Package and deploy to GitHub, no resource package 404 error found

System Info

Additional context Add any other context about the problem here.

xiaoxian521 commented 3 years ago

After packaging, open http-server locally to allow the project to be fully OK, but the deployment of GitHub will report 404, and no resources can be found

as https://xiaoxian521.github.io/zh/standard/

xiaoxian521 commented 3 years ago

@yyx990803 You da, this problem has troubled me for a long time. Can you solve it and support you forever

kiaking commented 3 years ago

@xiaoxian521 I think you need to add base option...?

// .vitepress/config.js

module.exports = {
  base: '/standard/',
  ...
}
yuxino commented 3 years ago

@kiaking @xiaoxian521 i think i can answer this question .

This seems to be a dns issues . If you are in China, you can try to use a global proxy.

When i turn off the proxy, i also can't access this site.

xiaoxian521 commented 3 years ago

The access path is as follows: https://xiaoxian521.github.io/

I am here config.js base: "/" is added to the, but it still doesn't work

xiaoxian521 commented 3 years ago

@yuxino But there is no problem with vuepress,It should be the same

yuxino commented 3 years ago

@xiaoxian521 i can't access any github.io site today , i think it's same question not vitepress. u can't access that http://elemefe.github.io/mint-ui, right ?

xiaoxian521 commented 3 years ago

@yuxino I can open it http://elemefe.github.io/mint-ui

kiaking commented 3 years ago

Oh wait, yea yea yea I recall this issue. We can't use underscore as a folder name in GitHub pages. So _assets folders doesn't work. We need to add .nojekyll file to the root.

@xiaoxian521 As a workaround, could you test placing public/.nojekyll file, and then deploy the build?

xiaoxian521 commented 3 years ago

Perfect solution. Thank you very much

kiaking commented 3 years ago

Nice! OK let's make this issue an enhancement issue. Maybe we could automatically include .nojekyll file at the built time, or maybe we should rename _assets folder to asstes like VuePress does.

xiaoxian521 commented 3 years ago

I support it very much

xiaoxian521 commented 3 years ago

Of course, another way is to configure deploy.sh file as

#!/usr/bin/env sh

# 确保脚本抛出遇到的错误
set -e

# 生成静态文件
npm run docs:build

# 进入生成的文件夹
cd docs/.vitepress/dist

touch .nojekyll

# 如果是发布到自定义域名
# echo 'www.example.com' > CNAME

git init
git add -A
git commit -m 'deploy'

# 如果发布到 https://<USERNAME>.github.io
git push -f git@github.com:xiaoxian521/xiaoxian521.github.io.git master:main

# 如果发布到 https://<USERNAME>.github.io/<REPO>
# git push -f git@github.com:<USERNAME>/<REPO>.git master:gh-pages

cd -
kiaking commented 3 years ago

Yeah that works too 👍

patak-dev commented 3 years ago

@kiaking in Vite 2, _assets was renamed to assets. This issue could be closed.

kiaking commented 3 years ago

! Actually I didn't know that. Maybe we should update docs about .nojekyll warning? (remove the alert) https://vitepress.vuejs.org/guide/deploy.html#github-pages

patak-dev commented 3 years ago

Yes, I forgot about that alert! I can send a PR removing it if you want 👍🏼

It is actually configurable now: https://vitejs.dev/config/#build-assetsdir But the default is assets, which is great 🙂

kiaking commented 3 years ago

Great! PR would be awesome 🙌 Not sure if adding .nojekyll is still preferable as a best practice, but even in that case I think we should just include .nojekyll at build time (if anyone one has problem related to it, then we would probably get anotehr issue opened so 😃 ).

zain12321 commented 1 year ago