diff --git a/packages/plugin-legacy/src/index.ts b/packages/plugin-legacy/src/index.ts index d7f0bb206547aa..0f8b7a8bdf7487 100644 --- a/packages/plugin-legacy/src/index.ts +++ b/packages/plugin-legacy/src/index.ts @@ -325,10 +325,6 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { } config = _config - if (!genLegacy || config.build.ssr) { - return - } - targets = options.targets || browserslistLoadConfig({ path: config.root }) || @@ -339,6 +335,10 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { isDebug && console.log(`[@vitejs/plugin-legacy] modernTargets:`, modernTargets) + if (!genLegacy || config.build.ssr) { + return + } + const getLegacyOutputFileName = ( fileNames: | string