fix(renderer): fix problem with HTMLPlugin's minify option (#3392)

This commit is contained in:
Pooya Parsa 2018-06-01 15:53:57 +04:30
parent 7540213996
commit 1f0053c160
1 changed files with 12 additions and 2 deletions

View File

@ -279,6 +279,16 @@ export default class Renderer {
this.useMiddleware(errorMiddleware.bind(this)) this.useMiddleware(errorMiddleware.bind(this))
} }
renderTemplate(ssr, opts) {
// Fix problem with HTMLPlugin's minify option (#3392)
opts.html_attrs = opts.HTML_ATTRS
opts.body_attrs = opts.BODY_ATTRS
const fn = ssr ? this.resources.ssrTemplate : this.resources.spaTemplate
return fn(opts)
}
async renderRoute(url, context = {}) { async renderRoute(url, context = {}) {
/* istanbul ignore if */ /* istanbul ignore if */
if (!this.isReady) { if (!this.isReady) {
@ -320,7 +330,7 @@ export default class Renderer {
throw err throw err
} }
const html = this.resources.spaTemplate({ const html = this.renderTemplate(false, {
HTML_ATTRS, HTML_ATTRS,
BODY_ATTRS, BODY_ATTRS,
HEAD, HEAD,
@ -376,7 +386,7 @@ export default class Renderer {
// TODO: vue-ssr need to handle https://github.com/vuejs/vue/issues/7897 // TODO: vue-ssr need to handle https://github.com/vuejs/vue/issues/7897
HEAD += context.renderStyles() HEAD += context.renderStyles()
let html = this.resources.ssrTemplate({ const html = this.renderTemplate(true, {
HTML_ATTRS: 'data-n-head-ssr ' + m.htmlAttrs.text(), HTML_ATTRS: 'data-n-head-ssr ' + m.htmlAttrs.text(),
BODY_ATTRS: m.bodyAttrs.text(), BODY_ATTRS: m.bodyAttrs.text(),
HEAD, HEAD,