mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
fix: modulepreload warnings (#6118)
This commit is contained in:
parent
c6f0f5d954
commit
76b1167d27
@ -113,9 +113,11 @@ const defaultPushAssets = (preloadFiles, shouldPush, publicPath, options) => {
|
||||
|
||||
const { crossorigin } = options.build
|
||||
const cors = `${crossorigin ? ` crossorigin=${crossorigin};` : ''}`
|
||||
const ref = modern ? 'modulepreload' : 'preload'
|
||||
// `modulepreload` rel attribute only supports script-like `as` value
|
||||
// https://html.spec.whatwg.org/multipage/links.html#link-type-modulepreload
|
||||
const rel = modern && asType === 'script' ? 'modulepreload' : 'preload'
|
||||
|
||||
links.push(`<${publicPath}${file}>; rel=${ref};${cors} as=${asType}`)
|
||||
links.push(`<${publicPath}${file}>; rel=${rel};${cors} as=${asType}`)
|
||||
})
|
||||
return links
|
||||
}
|
||||
|
@ -109,7 +109,8 @@ export default class SPARenderer extends BaseRenderer {
|
||||
if (asType === 'font') {
|
||||
extra = ` type="font/${extension}"${cors ? '' : ' crossorigin'}`
|
||||
}
|
||||
return `<link rel="${modern ? 'module' : ''}preload"${cors} href="${publicPath}${file}"${
|
||||
const rel = modern && asType === 'script' ? 'modulepreload' : 'preload'
|
||||
return `<link rel="${rel}"${cors} href="${publicPath}${file}"${
|
||||
asType !== '' ? ` as="${asType}"` : ''}${extra}>`
|
||||
})
|
||||
.join('')
|
||||
|
Loading…
Reference in New Issue
Block a user