File tree 3 files changed +12
-4
lines changed
3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -145,3 +145,7 @@ export const wildcardHosts = new Set([
145
145
'::' ,
146
146
'0000:0000:0000:0000:0000:0000:0000:0000' ,
147
147
] )
148
+
149
+ export const DEFAULT_DEV_PORT = 5173
150
+
151
+ export const DEFAULT_PREVIEW_PORT = 4173
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import compression from './server/middlewares/compression'
17
17
import { proxyMiddleware } from './server/middlewares/proxy'
18
18
import { resolveHostname , resolveServerUrls , shouldServeFile } from './utils'
19
19
import { printServerUrls } from './logger'
20
+ import { DEFAULT_PREVIEW_PORT } from './constants'
20
21
import { resolveConfig } from '.'
21
22
import type { InlineConfig , ResolvedConfig } from '.'
22
23
@@ -139,7 +140,7 @@ export async function preview(
139
140
140
141
const options = config . preview
141
142
const hostname = await resolveHostname ( options . host )
142
- const port = options . port ?? 4173
143
+ const port = options . port ?? DEFAULT_PREVIEW_PORT
143
144
const protocol = options . https ? 'https' : 'http'
144
145
const logger = config . logger
145
146
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ import {
40
40
} from '../optimizer'
41
41
import { bindShortcuts } from '../shortcuts'
42
42
import type { BindShortcutsOptions } from '../shortcuts'
43
- import { CLIENT_DIR } from '../constants'
43
+ import { CLIENT_DIR , DEFAULT_DEV_PORT } from '../constants'
44
44
import type { Logger } from '../logger'
45
45
import { printServerUrls } from '../logger'
46
46
import { invalidatePackageData } from '../packages'
@@ -661,7 +661,7 @@ async function startServer(
661
661
}
662
662
663
663
const options = server . config . server
664
- const port = inlinePort ?? options . port ?? 5173
664
+ const port = inlinePort ?? options . port ?? DEFAULT_DEV_PORT
665
665
const hostname = await resolveHostname ( options . host )
666
666
667
667
const protocol = options . https ? 'https' : 'http'
@@ -809,7 +809,10 @@ async function restartServer(server: ViteDevServer) {
809
809
if ( ! middlewareMode ) {
810
810
await server . listen ( port , true )
811
811
logger . info ( 'server restarted.' , { timestamp : true } )
812
- if ( ( port ?? 5173 ) !== ( prevPort ?? 5173 ) || host !== prevHost ) {
812
+ if (
813
+ ( port ?? DEFAULT_DEV_PORT ) !== ( prevPort ?? DEFAULT_DEV_PORT ) ||
814
+ host !== prevHost
815
+ ) {
813
816
logger . info ( '' )
814
817
server . printUrls ( )
815
818
}
You can’t perform that action at this time.
0 commit comments