mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
chore: update to vue-bundle-renderer 0.1.x
This commit is contained in:
parent
463e1d2bb4
commit
ade89f1067
@ -11,7 +11,7 @@ import ServerContext from 'src/server/context'
|
|||||||
import BaseRenderer from './base'
|
import BaseRenderer from './base'
|
||||||
|
|
||||||
export default class SSRRenderer extends BaseRenderer {
|
export default class SSRRenderer extends BaseRenderer {
|
||||||
vueRenderer: typeof import('@vue/server-renderer')
|
vueRenderer: ReturnType<typeof createBundleRenderer>
|
||||||
|
|
||||||
constructor (serverContext: ServerContext) {
|
constructor (serverContext: ServerContext) {
|
||||||
super(serverContext)
|
super(serverContext)
|
||||||
@ -23,6 +23,7 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
vueServerRenderer: require('@vue/server-renderer'),
|
vueServerRenderer: require('@vue/server-renderer'),
|
||||||
|
bundleRunner: require('bundle-runner'),
|
||||||
clientManifest: this.serverContext.resources.clientManifest,
|
clientManifest: this.serverContext.resources.clientManifest,
|
||||||
// for globally installed nuxt command, search dependencies in global dir
|
// for globally installed nuxt command, search dependencies in global dir
|
||||||
basedir: hasModules ? this.options.rootDir : __dirname,
|
basedir: hasModules ? this.options.rootDir : __dirname,
|
||||||
@ -30,8 +31,7 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderScripts (renderContext) {
|
renderScripts (scripts) {
|
||||||
const scripts = renderContext.renderScripts()
|
|
||||||
const { render: { crossorigin } } = this.options
|
const { render: { crossorigin } } = this.options
|
||||||
if (!crossorigin) {
|
if (!crossorigin) {
|
||||||
return scripts
|
return scripts
|
||||||
@ -46,8 +46,7 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
return renderContext.getPreloadFiles()
|
return renderContext.getPreloadFiles()
|
||||||
}
|
}
|
||||||
|
|
||||||
renderResourceHints (renderContext) {
|
renderResourceHints (resourceHints) {
|
||||||
const resourceHints = renderContext.renderResourceHints()
|
|
||||||
const { render: { crossorigin } } = this.options
|
const { render: { crossorigin } } = this.options
|
||||||
if (!crossorigin) {
|
if (!crossorigin) {
|
||||||
return resourceHints
|
return resourceHints
|
||||||
@ -94,7 +93,8 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
const getSSRLog = this.useSSRLog()
|
const getSSRLog = this.useSSRLog()
|
||||||
|
|
||||||
// Call Vue renderer renderToString
|
// Call Vue renderer renderToString
|
||||||
let APP = await this.vueRenderer.renderToString(renderContext)
|
const { html: _html, renderResourceHints, renderScripts, renderStyles } = await this.vueRenderer.renderToString(renderContext)
|
||||||
|
let APP = _html
|
||||||
|
|
||||||
// Wrap with Nuxt id
|
// Wrap with Nuxt id
|
||||||
APP = `<div id="${this.serverContext.globals.id}">${APP}</div>`
|
APP = `<div id="${this.serverContext.globals.id}">${APP}</div>`
|
||||||
@ -156,11 +156,11 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
|
|
||||||
// Inject resource hints
|
// Inject resource hints
|
||||||
if (this.options.render.resourceHints && shouldInjectScripts) {
|
if (this.options.render.resourceHints && shouldInjectScripts) {
|
||||||
HEAD += this.renderResourceHints(renderContext)
|
HEAD += this.renderResourceHints(renderResourceHints())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inject styles
|
// Inject styles
|
||||||
HEAD += renderContext.renderStyles()
|
HEAD += renderStyles()
|
||||||
|
|
||||||
if (meta) {
|
if (meta) {
|
||||||
const prependInjectorOptions = { pbody: true }
|
const prependInjectorOptions = { pbody: true }
|
||||||
@ -261,7 +261,7 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
|
|
||||||
// Prepend scripts
|
// Prepend scripts
|
||||||
if (shouldInjectScripts) {
|
if (shouldInjectScripts) {
|
||||||
APP += this.renderScripts(renderContext)
|
APP += this.renderScripts(renderScripts())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meta) {
|
if (meta) {
|
||||||
|
Loading…
Reference in New Issue
Block a user