set this.resources in constructor

Prevent error when access methods earlier than init is called
This commit is contained in:
Pooya Parsa 2017-06-14 21:41:38 +04:30
parent 4569b3a46f
commit de51b8a6da

View File

@ -31,6 +31,14 @@ export default class Renderer extends Tapable {
// Will be set by createRenderer
this.bundleRenderer = null
// Renderer runtime resources
this.resources = {
clientManifest: null,
serverBundle: null,
appTemplate: null,
errorTemplate: parseTemplate(fs.readFileSync(resolve(__dirname, 'views', 'error.html'), 'utf8'))
}
if (nuxt.initialized) {
// If nuxt already initialized
this._init = this.init().catch(this.nuxt.errorHandler)
@ -48,14 +56,6 @@ export default class Renderer extends Tapable {
return this._init
}
// Renderer runtime resources
this.resources = {
clientManifest: null,
serverBundle: null,
appTemplate: null,
errorTemplate: parseTemplate(fs.readFileSync(resolve(__dirname, 'views', 'error.html'), 'utf8'))
}
// For serving static/ files to /
this.serveStatic = pify(serveStatic(resolve(this.options.srcDir, 'static'), this.options.render.static))