mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-05 03:47:12 +00:00
Prevent nuxt dev crash if nuxt.config.js has problems
This commit is contained in:
parent
a315b71ea8
commit
5c6ebbfa16
24
bin/nuxt-dev
24
bin/nuxt-dev
@ -69,15 +69,29 @@ _.defaultsDeep(nuxtConfig, { watchers: { chokidar: { ignoreInitial: true } } })
|
||||
|
||||
// Start dev
|
||||
let dev = startDev()
|
||||
let reloadQueue = 0
|
||||
|
||||
// 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)
|
||||
reload()
|
||||
})
|
||||
|
||||
function reload() {
|
||||
++reloadQueue
|
||||
|
||||
dev = dev.then((nuxt) => {
|
||||
console.log('reloadQueue', reloadQueue)
|
||||
if (reloadQueue > 0) {
|
||||
debug('Rebuilding the app...')
|
||||
reloadQueue = 0
|
||||
return startDev(nuxt)
|
||||
}
|
||||
return nuxt;
|
||||
})
|
||||
}
|
||||
|
||||
function startDev(oldNuxt) {
|
||||
// Get latest environment variables
|
||||
@ -90,7 +104,7 @@ function startDev(oldNuxt) {
|
||||
options = loadNuxtConfig()
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
return // Wait for next reload
|
||||
return oldNuxt // Wait for next reload
|
||||
}
|
||||
|
||||
// Create nuxt and builder instance
|
||||
|
Loading…
Reference in New Issue
Block a user