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,