From 4451178c99b2a249f441c2813d572770494147a2 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Wed, 22 Nov 2017 00:33:37 +0300 Subject: [PATCH 1/3] Improved nuxt dev restart on config change (#2189) --- bin/nuxt-dev | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bin/nuxt-dev b/bin/nuxt-dev index bac6c1cb82..b2502e1da5 100755 --- a/bin/nuxt-dev +++ b/bin/nuxt-dev @@ -69,15 +69,23 @@ _.defaultsDeep(nuxtConfig, { watchers: { chokidar: { ignoreInitial: true } } }) // Start dev let dev = startDev() +let needToRestart = false // Start watching for nuxt.config.js changes chokidar .watch(nuxtConfigFile, nuxtConfig.watchers.chokidar) - .on('all', _.debounce(() => { + .on('all', () => { debug('[nuxt.config.js] changed') - debug('Rebuilding the app...') - dev = dev.then(startDev) - }), 2500) + needToRestart = true + + dev = dev.then((nuxt) => { + if (needToRestart === false) return nuxt + needToRestart = false + + debug('Rebuilding the app...') + return startDev(nuxt) + }) + }) function startDev(oldNuxt) { // Get latest environment variables From 8550bcd68437e8a92625b05b64dd098b75cb2bd8 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 22 Nov 2017 01:04:17 +0330 Subject: [PATCH 2/3] wChunk windows fix --- lib/common/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common/utils.js b/lib/common/utils.js index bc14e0b249..314c601536 100644 --- a/lib/common/utils.js +++ b/lib/common/utils.js @@ -107,7 +107,7 @@ export function wp(p = '') { export function wChunk(p = '') { /* istanbul ignore if */ if (isWindows) { - return p.replace(/\\/g, '/') + return p.replace(/\//g, '_') } return p } From 4c808c90ab7541c7b341f8ac2a225f4f9fca2f98 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Wed, 22 Nov 2017 12:51:07 +0300 Subject: [PATCH 3/3] fix memory leak on restart nuxt-dev (#2190) --- lib/builder/builder.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index a63e46950c..9427a41c2d 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -449,10 +449,16 @@ export default class Builder { return } // Server, build and watch for changes - compiler.watch(this.options.watchers.webpack, (err) => { + const watching = compiler.watch(this.options.watchers.webpack, (err) => { /* istanbul ignore if */ if (err) return reject(err) }) + + // Stop watching on nuxt.close() + this.nuxt.hook('close', () => { + watching.close() + }) + return } // --- Production Build ---