Skip to content

Commit

Permalink
fix(plugin-legacy): empty base makes import fail (fixes #4212) (#8387)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored May 29, 2022
1 parent 6673b3e commit 1a16f12
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
chunk.facadeModuleId
)
if (legacyEntryFilename) {
// `assets/foo.js` means importing "named register" in SystemJS
const nonBareBase = config.base === '' ? './' : config.base
tags.push({
tag: 'script',
attrs: {
Expand All @@ -427,7 +429,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
// script content will stay consistent - which allows using a constant
// hash value for CSP.
id: legacyEntryId,
'data-src': config.base + legacyEntryFilename
'data-src': nonBareBase + legacyEntryFilename
},
children: systemJSInlineCode,
injectTo: 'body'
Expand Down

0 comments on commit 1a16f12

Please sign in to comment.