Skip to content

Commit 3439132

Browse files
authored
chore: tweak server start output (#8582)
1 parent 73e1775 commit 3439132

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

packages/vite/src/node/logger.ts

+20-13
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ function printServerUrls(
173173
info: Logger['info']
174174
): void {
175175
const urls: Array<{ label: string; url: string }> = []
176+
const notes: Array<{ label: string; message: string }> = []
176177

177178
if (hostname.host && loopbackHosts.has(hostname.host)) {
178179
let hostnameName = hostname.name
@@ -191,9 +192,11 @@ function printServerUrls(
191192
})
192193

193194
if (hostname.name === 'localhost') {
194-
urls.push({
195-
label: 'Network',
196-
url: colors.dim(`use ${colors.white(colors.bold('--host'))} to expose`)
195+
notes.push({
196+
label: 'Hint',
197+
message: colors.dim(
198+
`Use ${colors.white(colors.bold('--host'))} to expose to network.`
199+
)
197200
})
198201
}
199202
} else {
@@ -217,9 +220,17 @@ function printServerUrls(
217220
})
218221
}
219222

220-
const length = urls.reduce(
221-
(length, { label }) => Math.max(length, label.length),
222-
0
223+
if (!hostname.host || wildcardHosts.has(hostname.host)) {
224+
notes.push({
225+
label: 'Note',
226+
message: colors.dim(
227+
'You are using a wildcard host. Ports might be overriden.'
228+
)
229+
})
230+
}
231+
232+
const length = Math.max(
233+
...[...urls, ...notes].map(({ label }) => label.length)
223234
)
224235
const print = (
225236
iconWithColor: string,
@@ -236,11 +247,7 @@ function printServerUrls(
236247
urls.forEach(({ label, url: text }) => {
237248
print(colors.green('➜'), label, text)
238249
})
239-
if (!hostname.host || wildcardHosts.has(hostname.host)) {
240-
print(
241-
colors.bold(colors.blue('ⓘ')),
242-
'Note',
243-
colors.dim('You are using a wildcard host. Ports might be overriden.')
244-
)
245-
}
250+
notes.forEach(({ label, message: text }) => {
251+
print(colors.white('❖'), label, text)
252+
})
246253
}

0 commit comments

Comments
 (0)