update tapable plugins

This commit is contained in:
Pooya Parsa 2017-07-30 16:17:50 +04:30
parent 8563c0f05f
commit 1417dae99b
3 changed files with 9 additions and 10 deletions

View File

@ -18,7 +18,7 @@ export default class ModuleContainer extends Tapable {
async _ready () {
await sequence(this.options.modules, this.addModule.bind(this))
await this.nuxt.applyPluginsAsync('module', this)
await this.applyPluginsAsync('ready', this)
}
addVendor (vendor) {

View File

@ -74,7 +74,7 @@ export default class Nuxt extends Tapable {
})
}))
resolve()
resolve(this.applyPluginsAsync('listen', { server, port, host }))
})
// Add server.destroy(cb) method

View File

@ -46,14 +46,12 @@ export default class Renderer extends Tapable {
spaTemplate: null,
errorTemplate: parseTemplate('<pre>{{ stack }}</pre>') // Will be loaded on ready
}
// Bind middleware to this context
this.nuxtMiddleware = this.nuxtMiddleware.bind(this)
this.errorMiddleware = this.errorMiddleware.bind(this)
}
async _ready () {
// Setup all middleWare
await this.nuxt.applyPluginsAsync('renderer', this)
// Setup nuxt middleware
await this.setupMiddleware()
// Load error template
@ -67,7 +65,8 @@ export default class Renderer extends Tapable {
await this.loadResources()
}
await this.nuxt.applyPluginsAsync('renderer', this)
// Call ready plugin
await this.applyPluginsAsync('ready', this)
}
async loadResources (_fs = fs) {
@ -211,10 +210,10 @@ export default class Renderer extends Tapable {
})
// Finally use nuxtMiddleware
this.useMiddleware(this.nuxtMiddleware)
this.useMiddleware(this.nuxtMiddleware.bind(this))
// Error middleware for errors that occurred in middleware that declared above
this.useMiddleware(this.errorMiddleware)
this.useMiddleware(this.errorMiddleware.bind(this))
}
async nuxtMiddleware (req, res, next) {