mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
fix(vue-renderer): use modulepreload
for modern mode spa generate (#5489)
This commit is contained in:
parent
8b15af79e7
commit
87fcf556a4
@ -30,8 +30,9 @@ export default class SPAMetaRenderer {
|
|||||||
return vm.$meta().inject()
|
return vm.$meta().inject()
|
||||||
}
|
}
|
||||||
|
|
||||||
async render({ url = '/', req = {} }) {
|
async render({ url = '/', req = {}, _generate }) {
|
||||||
const cacheKey = `${req.modernMode ? 'modern:' : 'legacy:'}${url}`
|
const modern = req.modernMode || (this.options.modern && _generate)
|
||||||
|
const cacheKey = `${modern ? 'modern:' : 'legacy:'}${url}`
|
||||||
let meta = this.cache.get(cacheKey)
|
let meta = this.cache.get(cacheKey)
|
||||||
|
|
||||||
if (meta) {
|
if (meta) {
|
||||||
@ -75,7 +76,7 @@ export default class SPAMetaRenderer {
|
|||||||
meta.resourceHints = ''
|
meta.resourceHints = ''
|
||||||
|
|
||||||
const { resources: { modernManifest, clientManifest } } = this.renderer.context
|
const { resources: { modernManifest, clientManifest } } = this.renderer.context
|
||||||
const manifest = req.modernMode ? modernManifest : clientManifest
|
const manifest = modern ? modernManifest : clientManifest
|
||||||
|
|
||||||
const { shouldPreload, shouldPrefetch } = this.options.render.bundleRenderer
|
const { shouldPreload, shouldPrefetch } = this.options.render.bundleRenderer
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ export default class SPAMetaRenderer {
|
|||||||
meta.preloadFiles = manifest.initial
|
meta.preloadFiles = manifest.initial
|
||||||
.map(SPAMetaRenderer.normalizeFile)
|
.map(SPAMetaRenderer.normalizeFile)
|
||||||
.filter(({ fileWithoutQuery, asType }) => shouldPreload(fileWithoutQuery, asType))
|
.filter(({ fileWithoutQuery, asType }) => shouldPreload(fileWithoutQuery, asType))
|
||||||
.map(file => ({ ...file, modern: req.modernMode }))
|
.map(file => ({ ...file, modern }))
|
||||||
|
|
||||||
meta.resourceHints += meta.preloadFiles
|
meta.resourceHints += meta.preloadFiles
|
||||||
.map(({ file, extension, fileWithoutQuery, asType, modern }) => {
|
.map(({ file, extension, fileWithoutQuery, asType, modern }) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user