File tree Expand file tree Collapse file tree
packages/astro/src/core/preview Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' astro ' : minor
3+ ---
4+
5+ Adds new CLI shortcuts available when running ` astro preview ` :
6+
7+ - ` o ` + ` enter ` : open the site in your browser
8+ - ` q ` + ` enter ` : quit the preview
9+ - ` h ` + ` enter ` : print all available shortcuts
Original file line number Diff line number Diff line change 11import type http from 'node:http' ;
22import { performance } from 'node:perf_hooks' ;
33import { fileURLToPath } from 'node:url' ;
4+ import type * as vite from 'vite' ;
45import { preview , type PreviewServer as VitePreviewServer } from 'vite' ;
56import type { AstroSettings } from '../../types/astro.js' ;
67import type { Logger } from '../logger/core.js' ;
@@ -47,6 +48,20 @@ export default async function createStaticPreviewServer(
4748 throw err ;
4849 }
4950
51+ // Set up shortcuts
52+
53+ const customShortcuts : Array < vite . CLIShortcut > = [
54+ // Disable default Vite shortcuts that don't work well with Astro
55+ { key : 'r' , description : '' } ,
56+ { key : 'u' , description : '' } ,
57+ { key : 'c' , description : '' } ,
58+ { key : 's' , description : '' } ,
59+ ] ;
60+
61+ previewServer . bindCLIShortcuts ( {
62+ customShortcuts,
63+ } ) ;
64+
5065 // Log server start URLs
5166 logger . info (
5267 'SKIP_FORMAT' ,
You can’t perform that action at this time.
0 commit comments