Skip to content

Commit 78174dc

Browse files
rocwangGuillaume Chau
authored andcommitted
fix(modern): fix the failure of modern build when the output HTML filename contain subdirectories
fix vuejs#1791
1 parent c9f8920 commit 78174dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ModernModePlugin {
2424
compilation.hooks.htmlWebpackPluginAlterAssetTags.tapAsync(ID, async (data, cb) => {
2525
// get stats, write to disk
2626
await fs.ensureDir(this.targetDir)
27-
const htmlName = data.plugin.options.filename
27+
const htmlName = path.basename(data.plugin.options.filename)
2828
const tempFilename = path.join(this.targetDir, `legacy-assets-${htmlName}.json`)
2929
await fs.writeFile(tempFilename, JSON.stringify(data.body))
3030
cb()
@@ -51,7 +51,7 @@ class ModernModePlugin {
5151
})
5252

5353
// inject links for legacy assets as <script nomodule>
54-
const htmlName = data.plugin.options.filename
54+
const htmlName = path.basename(data.plugin.options.filename)
5555
const tempFilename = path.join(this.targetDir, `legacy-assets-${htmlName}.json`)
5656
const legacyAssets = JSON.parse(await fs.readFile(tempFilename, 'utf-8'))
5757
.filter(a => a.tagName === 'script')

0 commit comments

Comments
 (0)