Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/nuxi/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default defineNuxtCommand({
}

const listener = await listen(serverHandler, {
showURL: false,
clipboard: args.clipboard,
open: args.open || args.o,
port: args.port || args.p || process.env.NUXT_PORT,
Expand All @@ -50,6 +51,12 @@ export default defineNuxtCommand({
const { loadNuxt, buildNuxt } = await loadKit(rootDir)

let currentNuxt: Nuxt
const showURL = () => {
listener.showURL({
// TODO: Normalize URL with trailing slash within schema
baseURL: withTrailingSlash(currentNuxt?.options.app.baseURL) || '/'
})
}
const load = async (isRestart: boolean, reason?: string) => {
try {
loadingMessage = `${reason ? reason + '. ' : ''}${isRestart ? 'Restarting' : 'Starting'} nuxt...`
Expand All @@ -61,6 +68,10 @@ export default defineNuxtCommand({
await currentNuxt.close()
}
currentNuxt = await loadNuxt({ rootDir, dev: true, ready: false })
if (!isRestart) {
showURL()
}

await currentNuxt.ready()
await currentNuxt.hooks.callHook('listen', listener.server, listener)
await Promise.all([
Expand All @@ -70,7 +81,7 @@ export default defineNuxtCommand({
currentHandler = currentNuxt.server.app
if (isRestart && args.clear !== false) {
showBanner()
listener.showURL()
showURL()
}
} catch (err) {
consola.error(`Cannot ${isRestart ? 'restart' : 'start'} nuxt: `, err)
Expand Down