diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/index.js index 1c8020877301e2..77f840cc811e99 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/index.js @@ -69,6 +69,15 @@ function viteLegacyPlugin(options = {}) { name: 'legacy-generate-polyfill-chunk', apply: 'build', + configResolved(config) { + if (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.` + ) + } + }, + async generateBundle(opts, bundle) { if (!isLegacyOutput(opts)) { if (!modernPolyfills.size) {