使用bun搭建一个vitepress个人笔记站点

342 阅读1分钟

2025年3月23日

笔者:ryanho

好久没更新了(好久没有水文章了),最近了解到bun想测试一下怎么样,正巧我之前搭的vitepress也想重建一下,接下来试一遍。

1.安装bun

www.bun.sh.cn/docs/instal…

从这个中文站看到,windows安装需要最低 Windows 10 版本为 1809。

我的系统版本22H2应该是够用了。

powershell -c "irm bun.sh/install.ps1|iex"

安装成功之后重启cmd或者powershell:

bun -v
1.2.5

说明成功安装。

2.创建vitepress项目

打开vscode,创建blog文件夹,打开终端并输入:

bun add -D vitepress

安装完成,用时15.06s。

PS E:\study\Blog> bun add -D vitepress
bun add v1.2.5 (013fdddc)
​
installed vitepress@1.6.3 with binaries:
 - vitepress
​
125 packages installed [15.06s]

初始化vitepress项目:

bun vitepress init

接下来按vitepress.dev/zh/guide/ge…说法回答几个问题。

  Welcome to VitePress!

  Where should VitePress initialize the config?
  ./docs

  Where should VitePress look for your markdown files?
  ./docs

  Site title:
  My Awesome Project

  Site description:
  A VitePress Site

  Theme:
  Default Theme

  Use TypeScript for config and theme files?
  Yes

  Add VitePress npm scripts to package.json?
  Yes

  Add a prefix for VitePress npm scripts?
  Yes

  Prefix for VitePress npm scripts:
  docs

  Done! Now run pnpm run docs:dev and start writing.

创建好后启动项目:

bun run docs:dev

项目成功跑起来了,接下来替换我之前写过的内容进来,看一下HMR热更新如何。

短暂测试了一遍没出现任何问题,热更新也蛮快。

3.打包测试

接下来测试打包和本地部署。

bun run docs:build
$ vitepress build blog
Debugger attached.
​
  vitepress v1.6.3
​
✓ building client + server bundles...
✓ rendering pages...
build complete in 7.17s.
Waiting for the debugger to disconnect...

将dist放在iis上访问。

测试没有问题。

Snipaste_2025-03-23_16-31-41.png