Skip to content

Commit

Permalink
feat: refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
ygj6 committed Jul 14, 2021
1 parent 81298a3 commit 61dbb3a
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions packages/vite/src/node/preview.ts
Expand Up @@ -57,30 +57,26 @@ export async function preview(
const logger = config.logger
const base = config.base

await httpServerStart(httpServer, {
const serverPort = await httpServerStart(httpServer, {
port,
strict: !!serverOptions.port,
host: hostname.host,
logger
})
.then((serverPort) => {
logger.info(
chalk.cyan(`\n vite v${require('vite/package.json').version}`) +
chalk.green(` build preview server running at:\n`)
)

printServerUrls(hostname, protocol, serverPort, base, logger.info)
logger.info(
chalk.cyan(`\n vite v${require('vite/package.json').version}`) +
chalk.green(` build preview server running at:\n`)
)

if (options.open) {
const path = typeof options.open === 'string' ? options.open : base
openBrowser(
`${protocol}://${hostname.name}:${serverPort}${path}`,
true,
logger
)
}
})
.catch((e) => {
throw e
})
printServerUrls(hostname, protocol, serverPort, base, logger.info)

if (options.open) {
const path = typeof options.open === 'string' ? options.open : base
openBrowser(
`${protocol}://${hostname.name}:${serverPort}${path}`,
true,
logger
)
}
}

0 comments on commit 61dbb3a

Please sign in to comment.