From 1f0053c1600ec9bcdba9ac659c30dc437f85410e Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 1 Jun 2018 15:53:57 +0430 Subject: [PATCH] fix(renderer): fix problem with HTMLPlugin's minify option (#3392) --- lib/core/renderer.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/core/renderer.js b/lib/core/renderer.js index 40884cad99..cfa3449acd 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -279,6 +279,16 @@ export default class Renderer { 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 = {}) { /* istanbul ignore if */ if (!this.isReady) { @@ -320,7 +330,7 @@ export default class Renderer { throw err } - const html = this.resources.spaTemplate({ + const html = this.renderTemplate(false, { HTML_ATTRS, BODY_ATTRS, HEAD, @@ -376,7 +386,7 @@ export default class Renderer { // TODO: vue-ssr need to handle https://github.com/vuejs/vue/issues/7897 HEAD += context.renderStyles() - let html = this.resources.ssrTemplate({ + const html = this.renderTemplate(true, { HTML_ATTRS: 'data-n-head-ssr ' + m.htmlAttrs.text(), BODY_ATTRS: m.bodyAttrs.text(), HEAD,