diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/index.js index ac7abf75893c99..fbcb6789761086 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/index.js @@ -97,7 +97,7 @@ function viteLegacyPlugin(options = {}) { apply: 'build', configResolved(config) { - if (!config.build.ssr && config.build.minify === 'esbuild') { + if (!config.build.ssr && genLegacy && config.build.minify === 'esbuild') { throw new Error( `Can't use esbuild as the minifier when targeting legacy browsers ` + `because esbuild minification is not legacy safe.`