vuejs / vitepress

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

How to deploy vitepress using vercel #3628

Closed zhanshenxiaomao closed 2 months ago

zhanshenxiaomao commented 2 months ago

Screenshot_20240303_124926_com android chrome

brc-dd commented 2 months ago

Configure your build commands and dist directory properly in vercel (https://vercel.com/docs/deployments/configure-a-build). It should've auto-detected them if you've selected vitepress preset.

zhanshenxiaomao commented 2 months ago

I still can't figure out how to do it. can you give me a chestnut @brc-dd

brc-dd commented 2 months ago

Open vercel dashboard. Click to your project. Click on settings. There you'll see something like this:

image

Adjust these commands to what you have locally. (For example if you locally have "docs:build": "vitepress build docs" in your package.json, you'll need to set build command as vitepress build docs and output directory to docs/.vitepress/dist

zhanshenxiaomao commented 2 months ago

Screenshot_20240303_143736

I think this screenshot might be useful @brc-dd

brc-dd commented 2 months ago

Did you forgot to run npm install?

zhanshenxiaomao commented 2 months ago

What

zhanshenxiaomao commented 2 months ago

I am using

npm add -D vitepress
brc-dd commented 2 months ago

At which directory? You had probably run that in different location.

zhanshenxiaomao commented 2 months ago

I'm really sorry. I seem to know the reason. I shouldn't be doing npm add -D vitepress in a certain folder

zhanshenxiaomao commented 2 months ago
[15:18:38] Running build in Washington, D.C., USA (East) – iad1
[15:18:38] Retrieving list of deployment files...
[15:18:38] Skipping build cache, deployment was triggered without cache.
[15:18:39] Downloading 36 deployment files...
[15:18:39] Running "vercel build"
[15:18:39] Vercel CLI 33.5.3
[15:18:40] Installing dependencies...
[15:18:40] yarn install v1.22.17
[15:18:40] warning package.json: No license field
[15:18:40] info No lockfile found.
[15:18:40] warning No license field
[15:18:40] [1/4] Resolving packages...
[15:18:40] [2/4] Fetching packages...
[15:18:40] [3/4] Linking dependencies...
[15:18:40] [4/4] Building fresh packages...
[15:18:40] success Saved lockfile.
[15:18:40] Done in 0.04s.
[15:18:40] sh: vitepress: command not found
[15:18:40] Error: Command "vitepress build docs" exited with 127
[15:18:41] 
brc-dd commented 2 months ago

Can you confirm that you have vitepress listed as dependency in your Test/package.json ?

zhanshenxiaomao commented 2 months ago

There is only so much content in the package.json file

{
  "scripts": {
    "docs:dev": "vitepress dev",
    "docs:build": "vitepress build",
    "docs:preview": "vitepress preview"
  }
}
brc-dd commented 2 months ago

That means you didn't run npm add -D vitepress in your Test directory.

zhanshenxiaomao commented 2 months ago

I think it’s still too late😭😭😭

zhanshenxiaomao commented 2 months ago

It's probably not too late now

zhanshenxiaomao commented 2 months ago

Screenshot_20240303_160939_com android chrome

brc-dd commented 2 months ago

You don't seem to have any page in your site. Can you show your directory structure, and build command and output directory settings?

zhanshenxiaomao commented 2 months ago
[16:10:24] Running build in Washington, D.C., USA (East) – iad1
[16:10:24] Retrieving list of deployment files...
[16:10:24] Skipping build cache, deployment was triggered without cache.
[16:10:24] Downloading 35 deployment files...
[16:10:25] Running "vercel build"
[16:10:26] Vercel CLI 33.5.3
[16:10:26] Installing dependencies...
[16:10:29] 
[16:10:29] added 79 packages in 2s
[16:10:29] 
[16:10:29] 10 packages are looking for funding
[16:10:29]   run `npm fund` for details
[16:10:30] 
[16:10:30]   vitepress v1.0.0-rc.44
[16:10:30] 
[16:10:30] - building client + server bundles...
[16:10:34] ✓ building client + server bundles...
[16:10:34] - rendering pages...
[16:10:34] ✓ rendering pages...
[16:10:34] build complete in 4.53s.
[16:10:34] Build Completed in /vercel/output [8s]
[16:10:34] Deploying outputs...
[16:10:35] 
[16:10:36] Deployment completed
[16:10:38] Uploading build cache [11.16 MB]...
[16:10:39] Build cache uploaded: 950.902ms
zhanshenxiaomao commented 2 months ago

https://wormhole.app/eqLxq#5gzS4ppPZMmF3OFbCB-tyQ

brc-dd commented 2 months ago

I think you have wrong config on vercel. Try logging into vercel.com and checking from dashboard there. It should be the same as what I shared in screenshot earlier.

zhanshenxiaomao commented 2 months ago

Screenshot_20240304_164054_com android chrome

brc-dd commented 2 months ago

Make them what I shared. You'll need to override because you are not using docs/ directory.

Build command - vitepress build\ Output directory - .vitepress/dist

zhanshenxiaomao commented 2 months ago

I didn't expect it to be because of this in the end. But solved. Thank you