Allow custom HTTP server instance from user

This commit is contained in:
Hana Shiro 2017-08-25 07:27:02 +08:00
parent cafc94d9f9
commit 22d5424caf
2 changed files with 11 additions and 2 deletions

View File

@ -225,6 +225,7 @@ Options.defaults = {
css: [],
modules: [],
layouts: {},
serverInstance: null,
serverMiddleware: [],
ErrorPage: null,
loading: {

View File

@ -39,8 +39,16 @@ export default class Renderer extends Tapable {
this.webpackDevMiddleware = null
this.webpackHotMiddleware = null
// Create new connect instance
this.app = connect()
if (typeof this.options.serverInstance === 'string') {
// Resolve the module from rootDir
this.app = require(this.nuxt.resolvePath(this.options.serverInstance))()
} else if (this.options.serverInstance instanceof Function) {
// Use the instance directly
this.app = this.options.serverInstance
} else {
// Create new connect instance
this.app = connect()
}
// Renderer runtime resources
this.resources = {