File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
packages/@vue/cli-service/lib/webpack Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class ModernModePlugin {
37
37
compiler . hooks . compilation . tap ( ID , compilation => {
38
38
compilation . hooks . htmlWebpackPluginAlterAssetTags . tapAsync ( ID , async ( data , cb ) => {
39
39
// use <script type="module"> for modern assets
40
- const modernAssets = data . body . filter ( a => a . tagName === 'script' )
40
+ const modernAssets = data . body . filter ( a => a . tagName === 'script' && a . attributes )
41
41
modernAssets . forEach ( a => {
42
42
a . attributes . type = 'module'
43
43
a . attributes . crossorigin = 'use-credentials'
@@ -54,7 +54,7 @@ class ModernModePlugin {
54
54
const htmlName = path . basename ( data . plugin . options . filename )
55
55
const tempFilename = path . join ( this . targetDir , `legacy-assets-${ htmlName } .json` )
56
56
const legacyAssets = JSON . parse ( await fs . readFile ( tempFilename , 'utf-8' ) )
57
- . filter ( a => a . tagName === 'script' )
57
+ . filter ( a => a . tagName === 'script' && a . attributes )
58
58
legacyAssets . forEach ( a => { a . attributes . nomodule = '' } )
59
59
data . body . push ( ...legacyAssets )
60
60
await fs . remove ( tempFilename )
You can’t perform that action at this time.
0 commit comments