Fix template not built

This commit is contained in:
Sébastien Chopin 2017-02-21 18:22:57 +00:00
parent 8dfae9fa54
commit 591ef50a06
2 changed files with 12 additions and 6 deletions

View File

@ -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
})
}
}

View File

@ -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
})