@@ -97,7 +97,7 @@ function viteLegacyPlugin(options = {}) {
97
97
apply : 'build' ,
98
98
99
99
configResolved ( config ) {
100
- if ( config . build . minify === 'esbuild' ) {
100
+ if ( ! config . build . ssr && config . build . minify === 'esbuild' ) {
101
101
throw new Error (
102
102
`Can't use esbuild as the minifier when targeting legacy browsers ` +
103
103
`because esbuild minification is not legacy safe.`
@@ -106,6 +106,10 @@ function viteLegacyPlugin(options = {}) {
106
106
} ,
107
107
108
108
async generateBundle ( opts , bundle ) {
109
+ if ( config . build . ssr ) {
110
+ return
111
+ }
112
+
109
113
if ( ! isLegacyBundle ( bundle , opts ) ) {
110
114
if ( ! modernPolyfills . size ) {
111
115
return
@@ -170,7 +174,7 @@ function viteLegacyPlugin(options = {}) {
170
174
}
171
175
config = _config
172
176
173
- if ( ! genLegacy ) {
177
+ if ( ! genLegacy || config . build . ssr ) {
174
178
return
175
179
}
176
180
@@ -226,6 +230,10 @@ function viteLegacyPlugin(options = {}) {
226
230
} ,
227
231
228
232
renderChunk ( raw , chunk , opts ) {
233
+ if ( config . build . ssr ) {
234
+ return
235
+ }
236
+
229
237
if ( ! isLegacyChunk ( chunk , opts ) ) {
230
238
if (
231
239
options . modernPolyfills &&
@@ -315,6 +323,7 @@ function viteLegacyPlugin(options = {}) {
315
323
} ,
316
324
317
325
transformIndexHtml ( html , { chunk } ) {
326
+ if ( config . build . ssr ) return
318
327
if ( ! chunk ) return
319
328
if ( chunk . fileName . includes ( '-legacy' ) ) {
320
329
// The legacy bundle is built first, and its index.html isn't actually
@@ -420,6 +429,10 @@ function viteLegacyPlugin(options = {}) {
420
429
} ,
421
430
422
431
generateBundle ( opts , bundle ) {
432
+ if ( config . build . ssr ) {
433
+ return
434
+ }
435
+
423
436
if ( isLegacyBundle ( bundle , opts ) ) {
424
437
// avoid emitting duplicate assets
425
438
for ( const name in bundle ) {
0 commit comments