Skip to content

Commit 1a16f12

Browse files
authored
fix(plugin-legacy): empty base makes import fail (fixes #4212) (#8387)
1 parent 6673b3e commit 1a16f12

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: packages/plugin-legacy/src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
419419
chunk.facadeModuleId
420420
)
421421
if (legacyEntryFilename) {
422+
// `assets/foo.js` means importing "named register" in SystemJS
423+
const nonBareBase = config.base === '' ? './' : config.base
422424
tags.push({
423425
tag: 'script',
424426
attrs: {
@@ -427,7 +429,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
427429
// script content will stay consistent - which allows using a constant
428430
// hash value for CSP.
429431
id: legacyEntryId,
430-
'data-src': config.base + legacyEntryFilename
432+
'data-src': nonBareBase + legacyEntryFilename
431433
},
432434
children: systemJSInlineCode,
433435
injectTo: 'body'

0 commit comments

Comments
 (0)