-
Notifications
You must be signed in to change notification settings - Fork 84
feat: add vitepress #6866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add vitepress #6866
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { beforeEach, expect, test } from 'vitest' | ||
|
|
||
| import { mockFileSystem } from '../../tests/mock-file-system.js' | ||
| import { NodeFS } from '../node/file-system.js' | ||
| import { Project } from '../project.js' | ||
|
|
||
| beforeEach((ctx) => { | ||
| ctx.fs = new NodeFS() | ||
| }) | ||
|
|
||
| test('detects a Vitepress site', async ({ fs }) => { | ||
| const cwd = mockFileSystem({ | ||
| 'package.json': JSON.stringify({ | ||
| private: true, | ||
| type: 'module', | ||
| scripts: { | ||
| 'docs:dev': 'vitepress dev docs', | ||
| 'docs:build': 'vitepress build docs', | ||
| 'docs:preview': 'vitepress preview docs', | ||
| }, | ||
| devDependencies: { | ||
| vitepress: '^2.0.0-alpha', | ||
| }, | ||
| }), | ||
| }) | ||
| const detected = await new Project(fs, cwd).detectFrameworks() | ||
|
|
||
| expect(detected?.length).toBe(1) | ||
|
|
||
| expect(detected?.[0]?.id).toBe('vitepress') | ||
| expect(detected?.[0]?.build?.command).toBe('vitepress build') | ||
| expect(detected?.[0]?.build?.directory).toBe('.vitepress/dist') | ||
| expect(detected?.[0]?.dev?.command).toBe('vitepress dev') | ||
| expect(detected?.[0]?.dev?.port).toBe(5173) | ||
| }) |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,25 @@ | ||||||||||
| import { BaseFramework, Category, Framework } from './framework.js' | ||||||||||
|
|
||||||||||
| export class VitePress extends BaseFramework implements Framework { | ||||||||||
| readonly id = 'vitepress' | ||||||||||
| name = 'VitePress' | ||||||||||
| npmDependencies = ['vitepress'] | ||||||||||
| category = Category.SSG | ||||||||||
|
|
||||||||||
| dev = { | ||||||||||
| command: 'vitepress dev', | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||||||
| port: 5173, | ||||||||||
| pollingStrategies: [{ name: 'TCP' }], | ||||||||||
| } | ||||||||||
|
|
||||||||||
| build = { | ||||||||||
| command: 'vitepress build', | ||||||||||
| directory: '.vitepress/dist', | ||||||||||
|
Comment on lines
+16
to
+17
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 π.
π€π€π€ 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
Suggested change
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... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think going with the "docs" folder is most common. Users can change it around if they deploy a "plain vitepress site". And the default command is shown in the Netlify UI too, right (so users will spot a mismatch)? |
||||||||||
| } | ||||||||||
|
|
||||||||||
| logo = { | ||||||||||
| default: '/logos/vitepress/default.svg', | ||||||||||
| light: '/logos/vitepress/default.svg', | ||||||||||
| dark: '/logos/vitepress/default.svg', | ||||||||||
| } | ||||||||||
| } | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's addvitepressto the big list of excluded dependencies forvite: https://github.com/dario-piotrowicz/netlify-build/blob/796ebb173d716151fe0e864c724be1e67c1cdd1c/packages/build-info/src/frameworks/vite.ts#L7Huh, never mind, vitepress projects don't have a direct dependency on vite!