@@ -25,7 +25,10 @@ class ModernModePlugin {
25
25
// get stats, write to disk
26
26
await fs . ensureDir ( this . targetDir )
27
27
const htmlName = path . basename ( data . plugin . options . filename )
28
- const tempFilename = path . join ( this . targetDir , `legacy-assets-${ htmlName } .json` )
28
+ // Watch out for output files in sub directories
29
+ const htmlPath = path . dirname ( data . plugin . options . filename )
30
+ const tempFilename = path . join ( this . targetDir , htmlPath , `legacy-assets-${ htmlName } .json` )
31
+ await fs . mkdirp ( path . dirname ( tempFilename ) )
29
32
await fs . writeFile ( tempFilename , JSON . stringify ( data . body ) )
30
33
cb ( )
31
34
} )
@@ -52,7 +55,9 @@ class ModernModePlugin {
52
55
53
56
// inject links for legacy assets as <script nomodule>
54
57
const htmlName = path . basename ( data . plugin . options . filename )
55
- const tempFilename = path . join ( this . targetDir , `legacy-assets-${ htmlName } .json` )
58
+ // Watch out for output files in sub directories
59
+ const htmlPath = path . dirname ( data . plugin . options . filename )
60
+ const tempFilename = path . join ( this . targetDir , htmlPath , `legacy-assets-${ htmlName } .json` )
56
61
const legacyAssets = JSON . parse ( await fs . readFile ( tempFilename , 'utf-8' ) )
57
62
. filter ( a => a . tagName === 'script' && a . attributes )
58
63
legacyAssets . forEach ( a => { a . attributes . nomodule = '' } )
0 commit comments