From f14ac05ce42f96ce5dd3a506385bc7eb0f936ed8 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 2 Apr 2018 00:26:59 +0430 Subject: [PATCH] perf(nuxt-dev): start first listen as fast as possible also fixes problem with showReady not showing on first compile --- bin/nuxt-dev | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/bin/nuxt-dev b/bin/nuxt-dev index 3ee622c686..526a9f4778 100755 --- a/bin/nuxt-dev +++ b/bin/nuxt-dev @@ -109,12 +109,13 @@ function startDev(oldInstance) { return ( Promise.resolve() - .then( - () => - oldInstance && oldInstance.builder - ? oldInstance.builder.unwatch() - : Promise.resolve() - ) + .then(() => { + if (oldInstance && oldInstance.builder) { + return oldInstance.builder.unwatch() + } else { + return nuxt.listen(port, host) + } + }) // Start build .then(() => builder.build()) // Close old nuxt after successful build @@ -125,7 +126,13 @@ function startDev(oldInstance) { : Promise.resolve() ) // Start listening - .then(() => nuxt.listen(port, host)) + .then(() => { + if (oldInstance) { + return nuxt.listen(port, host) + } else { + return Promise.resolve() + } + }) // Pass new nuxt to watch chain .then(() => instance) // Handle errors