Improved nuxt dev restart on config change (#2189)

This commit is contained in:
Dmitriy 2017-11-22 00:33:37 +03:00 committed by Pooya Parsa
parent c377a78e7d
commit 4451178c99

View File

@ -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')
needToRestart = true
dev = dev.then((nuxt) => {
if (needToRestart === false) return nuxt
needToRestart = false
debug('Rebuilding the app...')
dev = dev.then(startDev)
}), 2500)
return startDev(nuxt)
})
})
function startDev(oldNuxt) {
// Get latest environment variables