Skip to content

Commit

Permalink
fix(build): modern plugin when building multi page applications with …
Browse files Browse the repository at this point in the history
…output in sub directories (#1866)
  • Loading branch information
nparley authored and Akryum committed Jul 16, 2018
1 parent 8a09624 commit d3d827c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/@vue/cli-service/lib/webpack/ModernModePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class ModernModePlugin {
// get stats, write to disk
await fs.ensureDir(this.targetDir)
const htmlName = path.basename(data.plugin.options.filename)
const tempFilename = path.join(this.targetDir, `legacy-assets-${htmlName}.json`)
// Watch out for output files in sub directories
const htmlPath = path.dirname(data.plugin.options.filename)
const tempFilename = path.join(this.targetDir, htmlPath, `legacy-assets-${htmlName}.json`)
await fs.mkdirp(path.dirname(tempFilename))
await fs.writeFile(tempFilename, JSON.stringify(data.body))
cb()
})
Expand All @@ -52,7 +55,9 @@ class ModernModePlugin {

// inject links for legacy assets as <script nomodule>
const htmlName = path.basename(data.plugin.options.filename)
const tempFilename = path.join(this.targetDir, `legacy-assets-${htmlName}.json`)
// Watch out for output files in sub directories
const htmlPath = path.dirname(data.plugin.options.filename)
const tempFilename = path.join(this.targetDir, htmlPath, `legacy-assets-${htmlName}.json`)
const legacyAssets = JSON.parse(await fs.readFile(tempFilename, 'utf-8'))
.filter(a => a.tagName === 'script' && a.attributes)
legacyAssets.forEach(a => { a.attributes.nomodule = '' })
Expand Down

0 comments on commit d3d827c

Please sign in to comment.