Filter out non-strings (serverMiddleware watch fix) (#3771)

* Filter out non-strings

* Add serverMiddleware function

* Add serverMiddleware function (2)

* Add serverMiddleware function (3)
This commit is contained in:
Jonas Galvez 2018-08-20 11:43:23 -03:00 committed by Sébastien Chopin
parent b920f22483
commit f0f307553f
2 changed files with 7 additions and 2 deletions

View File

@ -643,7 +643,9 @@ export default class Builder {
watchServer() {
const nuxtRestartWatch = _.concat(
this.options.serverMiddleware.map(this.nuxt.resolveAlias),
this.options.serverMiddleware
.filter(i => typeof i === 'string')
.map(this.nuxt.resolveAlias),
this.options.watch.map(this.nuxt.resolveAlias),
path.join(this.options.rootDir, 'nuxt.config.js')
)

View File

@ -1,5 +1,8 @@
export default {
serverMiddleware: ['~/middleware.js'],
serverMiddleware: [
'~/middleware.js',
(req, res, next) => next()
],
watch: ['~/custom.file'],
hooks(hook) {
hook('listen', (server, { port, host }) => {