mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix: undefined script in modern mode
This commit is contained in:
parent
e8083fb3eb
commit
0a21d4b34c
@ -59,7 +59,11 @@ export default class VueRenderer {
|
||||
const modernJsFile = this.assetsMapping[legacyJsFile]
|
||||
const crossorigin = this.context.options.build.crossorigin
|
||||
const cors = `${crossorigin ? ` crossorigin="${crossorigin}"` : ''}`
|
||||
const moduleTag = scriptTag.replace('<script', `<script type="module"${cors}`).replace(legacyJsFile, modernJsFile)
|
||||
const moduleTag = modernJsFile
|
||||
? scriptTag
|
||||
.replace('<script', `<script type="module"${cors}`)
|
||||
.replace(legacyJsFile, modernJsFile)
|
||||
: ''
|
||||
const noModuleTag = scriptTag.replace('<script', `<script nomodule${cors}`)
|
||||
return noModuleTag + moduleTag
|
||||
})
|
||||
@ -95,6 +99,9 @@ export default class VueRenderer {
|
||||
return context.renderResourceHints().replace(linkPattern, (linkTag, jsFile) => {
|
||||
const legacyJsFile = jsFile.replace(publicPath, '')
|
||||
const modernJsFile = this.assetsMapping[legacyJsFile]
|
||||
if (!modernJsFile) {
|
||||
return ''
|
||||
}
|
||||
const crossorigin = this.context.options.build.crossorigin
|
||||
const cors = `${crossorigin ? ` crossorigin="${crossorigin}"` : ''}`
|
||||
return linkTag.replace('rel="preload"', `rel="modulepreload"${cors}`).replace(legacyJsFile, modernJsFile)
|
||||
|
Loading…
Reference in New Issue
Block a user