diff --git a/lib/core/meta.js b/lib/core/meta.js index 0df24a9de4..53398e16bb 100644 --- a/lib/core/meta.js +++ b/lib/core/meta.js @@ -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) diff --git a/lib/core/renderer.js b/lib/core/renderer.js index eff0ed19c0..9139eaf0de 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -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 = `
${this.resources.loadingHTML}
` + 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 += `` } - if (this.options.render.preloadLinks) { + if (this.options.render.resourceHints) { HEAD += context.renderResourceHints() } diff --git a/test/basic.ssr.test.js b/test/basic.ssr.test.js index 82ee3fe7ed..c18aaf5708 100755 --- a/test/basic.ssr.test.js +++ b/test/basic.ssr.test.js @@ -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)