Skip to content

Commit dbd9688

Browse files
authoredJun 18, 2022
feat: cleaner default dev output (#8638)
1 parent 11d2191 commit dbd9688

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed
 

‎packages/vite/src/node/logger.ts

+13-14
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function printServerUrls(
172172
base: string,
173173
info: Logger['info']
174174
): void {
175-
const urls: Array<{ label: string; url: string }> = []
175+
const urls: Array<{ label: string; url: string; disabled?: boolean }> = []
176176
const notes: Array<{ label: string; message: string }> = []
177177

178178
if (hostname.host && loopbackHosts.has(hostname.host)) {
@@ -192,11 +192,10 @@ function printServerUrls(
192192
})
193193

194194
if (hostname.name === 'localhost') {
195-
notes.push({
196-
label: 'Hint',
197-
message: colors.dim(
198-
`Use ${colors.white(colors.bold('--host'))} to expose to network.`
199-
)
195+
urls.push({
196+
label: 'Network',
197+
url: `use ${colors.white(colors.bold('--host'))} to expose`,
198+
disabled: true
200199
})
201200
}
202201
} else {
@@ -235,17 +234,17 @@ function printServerUrls(
235234
const print = (
236235
iconWithColor: string,
237236
label: string,
238-
messageWithColor: string
237+
messageWithColor: string,
238+
disabled?: boolean
239239
) => {
240-
info(
241-
` ${iconWithColor} ${colors.bold(label)}: ${' '.repeat(
242-
length - label.length
243-
)}${messageWithColor}`
244-
)
240+
const message = ` ${iconWithColor} ${
241+
label ? colors.bold(label) + ':' : ' '
242+
} ${' '.repeat(length - label.length)}${messageWithColor}`
243+
info(disabled ? colors.dim(message) : message)
245244
}
246245

247-
urls.forEach(({ label, url: text }) => {
248-
print(colors.green('➜'), label, text)
246+
urls.forEach(({ label, url: text, disabled }) => {
247+
print(colors.green('➜'), label, text, disabled)
249248
})
250249
notes.forEach(({ label, message: text }) => {
251250
print(colors.white('❖'), label, text)

0 commit comments

Comments
 (0)
Please sign in to comment.