Skip to content

Conversation

@dario-piotrowicz
Copy link
Contributor

This PR adds VitePress detection.

This PR is a recreation of #6630 from @TheAlexLichter since that PR got quite stale for a while (I hope you don't mind Alex 😄🙏)


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures
    we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
    something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures
    your code follows our style guide and passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner December 21, 2025 11:40
@dario-piotrowicz dario-piotrowicz force-pushed the dario/build-info-vitepress branch from 4b7e41c to 147a4bd Compare December 21, 2025 11:44
@serhalp serhalp mentioned this pull request Dec 29, 2025
5 tasks
Copy link
Member

@serhalp serhalp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Dario! Looks great overall — just a bit of a conundrum around what settings to populate 🤔.

Comment on lines +16 to +17
command: 'vitepress build',
directory: '.vitepress/dist',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Hmm, VitePress is an interesting case because of https://vitepress.dev/guide/routing#root-and-source-directory. It's doubly strange because the "project root" isn't even configurable; it's an ephemeral concept specified on the command line 🙃.

vitepress build foo emits build output into ./foo/.vitepress/dist. VitePress calls ./foo here the "project root". If you run vitepress build without a root arg, root is set to pwd, so the output ends up in ./vitepress/dist. This isn't entirely a build output concern—the project root is where the VitePress config file is expected, etc. so it needs to be correct.

🤔🤔🤔

I don't think it's possible to make this perfect. Perhaps the best we can do is use their current recommended config, which is compatible with the defaults emitted by npx vitepress init (i.e. project root = ./docs).

Suggested change
command: 'vitepress build',
directory: '.vitepress/dist',
command: 'vitepress build docs', // ideally we don't use `npm run build:docs` here due to pnpm, etc.
directory: 'docs/.vitepress/dist',

What do you think? We could do some hacky things inspecting the user build command, but I'm not sure that's worth the complexity...

category = Category.SSG

dev = {
command: 'vitepress dev',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See discussion below. If we want this to align with the defaults from npx vitepress init, we should use:

Suggested change
command: 'vitepress dev',
command: 'vitepress dev docs',

@@ -0,0 +1,25 @@
import { BaseFramework, Category, Framework } from './framework.js'

export class VitePress extends BaseFramework implements Framework {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add vitepress to the big list of excluded dependencies for vite: https://github.com/dario-piotrowicz/netlify-build/blob/796ebb173d716151fe0e864c724be1e67c1cdd1c/packages/build-info/src/frameworks/vite.ts#L7

Huh, never mind, vitepress projects don't have a direct dependency on vite!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants