@@ -34,12 +34,15 @@ import {
3434import { printServerUrls } from './logger'
3535import { bindCLIShortcuts } from './shortcuts'
3636import type { BindCLIShortcutsOptions } from './shortcuts'
37- import { configDefaults , resolveConfig } from './config'
37+ import { resolveConfig } from './config'
3838import type { InlineConfig , ResolvedConfig } from './config'
39+ import { DEFAULT_PREVIEW_PORT } from './constants'
40+ import type { RequiredExceptFor } from './typeUtils'
3941
4042export interface PreviewOptions extends CommonServerOptions { }
4143
42- export interface ResolvedPreviewOptions extends PreviewOptions { }
44+ export interface ResolvedPreviewOptions
45+ extends RequiredExceptFor < PreviewOptions , 'host' | 'https' | 'proxy' > { }
4346
4447export function resolvePreviewOptions (
4548 preview : PreviewOptions | undefined ,
@@ -49,7 +52,7 @@ export function resolvePreviewOptions(
4952 // except for the port to enable having both the dev and preview servers running
5053 // at the same time without extra configuration
5154 return {
52- port : preview ?. port ,
55+ port : preview ?. port ?? DEFAULT_PREVIEW_PORT ,
5356 strictPort : preview ?. strictPort ?? server . strictPort ,
5457 host : preview ?. host ?? server . host ,
5558 https : preview ?. https ?? server . https ,
@@ -243,10 +246,9 @@ export async function preview(
243246 }
244247
245248 const hostname = await resolveHostname ( options . host )
246- const port = options . port ?? configDefaults . preview . port
247249
248250 await httpServerStart ( httpServer , {
249- port,
251+ port : options . port ,
250252 strictPort : options . strictPort ,
251253 host : hostname . host ,
252254 logger,
0 commit comments