diff --git a/packages/plugin-legacy/src/index.ts b/packages/plugin-legacy/src/index.ts index 3a9fb253d4658a..bc21d4d917d8df 100644 --- a/packages/plugin-legacy/src/index.ts +++ b/packages/plugin-legacy/src/index.ts @@ -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: { @@ -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'