Skip to content

Commit d3d827c

Browse files
nparleyAkryum
authored andcommitted
fix(build): modern plugin when building multi page applications with output in sub directories (vuejs#1866)
1 parent 8a09624 commit d3d827c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/@vue/cli-service/lib/webpack/ModernModePlugin.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ class ModernModePlugin {
2525
// get stats, write to disk
2626
await fs.ensureDir(this.targetDir)
2727
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))
2932
await fs.writeFile(tempFilename, JSON.stringify(data.body))
3033
cb()
3134
})
@@ -52,7 +55,9 @@ class ModernModePlugin {
5255

5356
// inject links for legacy assets as <script nomodule>
5457
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`)
5661
const legacyAssets = JSON.parse(await fs.readFile(tempFilename, 'utf-8'))
5762
.filter(a => a.tagName === 'script' && a.attributes)
5863
legacyAssets.forEach(a => { a.attributes.nomodule = '' })

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy