mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Improved nuxt dev restart on config change (#2189)
This commit is contained in:
parent
c377a78e7d
commit
4451178c99
14
bin/nuxt-dev
14
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')
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user