Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/real-ends-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Enable CLI shortcuts for `astro preview`
15 changes: 15 additions & 0 deletions packages/astro/src/core/preview/static-preview-server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type http from 'node:http';
import { performance } from 'node:perf_hooks';
import { fileURLToPath } from 'node:url';
import type * as vite from 'vite';
import { preview, type PreviewServer as VitePreviewServer } from 'vite';
import type { AstroSettings } from '../../types/astro.js';
import type { Logger } from '../logger/core.js';
Expand Down Expand Up @@ -47,6 +48,20 @@ export default async function createStaticPreviewServer(
throw err;
}

// Set up shortcuts

const customShortcuts: Array<vite.CLIShortcut> = [
// Disable default Vite shortcuts that don't work well with Astro
{ key: 'r', description: '' },
{ key: 'u', description: '' },
{ key: 'c', description: '' },
{ key: 's', description: '' },
];

previewServer.bindCLIShortcuts({
customShortcuts,
});

// Log server start URLs
logger.info(
'SKIP_FORMAT',
Expand Down
Loading