minor fixes

This commit is contained in:
Pooya Parsa 2018-01-05 02:03:46 +03:30
parent aef2199402
commit 60714ecfc0
3 changed files with 11 additions and 5 deletions

View File

@ -74,6 +74,14 @@ module.exports = class MetaRenderer {
}
}
// Emulate getPreloadFiles from vue-server-renderer (works for JS chunks only)
meta.getPreloadFiles = () => clientManifest.initial.map(r => ({
file: r,
fileWithoutQuery: r,
asType: 'script',
extension: 'js'
}))
// Set meta tags inside cache
this.cache.set(url, meta)

View File

@ -280,7 +280,7 @@ module.exports = class Renderer {
const ENV = this.options.env
if (this.noSSR || spa) {
const { HTML_ATTRS, BODY_ATTRS, HEAD, BODY_SCRIPTS, resourceHints } = await this.metaRenderer.render(context)
const { HTML_ATTRS, BODY_ATTRS, HEAD, BODY_SCRIPTS, getPreloadFiles } = await this.metaRenderer.render(context)
const APP = `<div id="__nuxt">${this.resources.loadingHTML}</div>` + BODY_SCRIPTS
// Detect 404 errors
@ -297,7 +297,7 @@ module.exports = class Renderer {
ENV
})
return { html, resourceHints }
return { html, getPreloadFiles }
}
// Call renderToString from the bundleRenderer and generate the HTML (will update the context as well)
@ -312,7 +312,7 @@ module.exports = class Renderer {
HEAD += `<base href="${this.options.router.base}">`
}
if (this.options.render.preloadLinks) {
if (this.options.render.resourceHints) {
HEAD += context.renderResourceHints()
}

View File

@ -223,8 +223,6 @@ test('/no-ssr (client-side)', async t => {
test('ETag Header', async t => {
const { headers: { etag } } = await rp(url('/stateless'), { resolveWithFullResponse: true })
// Validate etag
t.regex(etag, /W\/".*"$/)
// Verify functionality
const error = await t.throws(rp(url('/stateless'), { headers: { 'If-None-Match': etag } }))
t.is(error.statusCode, 304)