From 591ef50a0641ef4f7ca167aeae0fe2a4860b3702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Tue, 21 Feb 2017 18:22:57 +0000 Subject: [PATCH] Fix template not built --- lib/build.js | 11 +++++++++++ lib/nuxt.js | 7 +------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/build.js b/lib/build.js index 488fda67b9..d3596cb3e9 100644 --- a/lib/build.js +++ b/lib/build.js @@ -101,6 +101,7 @@ export function options () { if (fs.existsSync(bundlePath)) { const bundle = fs.readFileSync(bundlePath, 'utf8') createRenderer.call(this, bundle) + addAppTemplate.call(this) } } } @@ -142,6 +143,16 @@ function * buildFiles () { webpackRunClient.call(this), webpackRunServer.call(this) ] + addAppTemplate.call(this) + } +} + +function addAppTemplate () { + let templatePath = resolve(this.dir, '.nuxt', 'dist', 'index.html') + if (fs.existsSync(templatePath)) { + this.appTemplate = _.template(fs.readFileSync(templatePath, 'utf8'), { + interpolate: /{{([\s\S]+?)}}/g + }) } } diff --git a/lib/nuxt.js b/lib/nuxt.js index ff97870b41..a049290ee9 100644 --- a/lib/nuxt.js +++ b/lib/nuxt.js @@ -84,12 +84,7 @@ class Nuxt { // Add this.build build.options.call(this) // Add build options this.build = () => co(build.build.bind(this)) - // Template - if (!this.dev && this.renderer) { - this.appTemplate = _.template(fs.readFileSync(resolve(this.dir, '.nuxt', 'dist', 'index.html'), 'utf8'), { - interpolate: /{{([\s\S]+?)}}/g - }) - } + // Error template this.errorTemplate = _.template(fs.readFileSync(resolve(__dirname, 'views', 'error.html'), 'utf8'), { interpolate: /{{([\s\S]+?)}}/g })