(config: ResolvedConfig)
| 513 | } |
| 514 | |
| 515 | export function resolveBuildPlugins(config: ResolvedConfig): { |
| 516 | pre: Plugin[] |
| 517 | post: Plugin[] |
| 518 | } { |
| 519 | const isBuild = config.command === 'build' |
| 520 | return { |
| 521 | pre: [ |
| 522 | ...(isBuild && !config.isWorker ? [prepareOutDirPlugin()] : []), |
| 523 | perEnvironmentPlugin( |
| 524 | 'vite:rollup-options-plugins', |
| 525 | async (environment) => { |
| 526 | if (!isBuild && !environment.config.isBundled) { |
| 527 | return false |
| 528 | } |
| 529 | return ( |
| 530 | await asyncFlatten( |
| 531 | arraify(environment.config.build.rolldownOptions.plugins), |
| 532 | ) |
| 533 | ).filter(Boolean) as Plugin[] |
| 534 | }, |
| 535 | ), |
| 536 | ...(config.isWorker ? [webWorkerPostPlugin(config)] : []), |
| 537 | ], |
| 538 | post: [ |
| 539 | ...(isBuild ? buildImportAnalysisPlugin(config) : []), |
| 540 | ...(isBuild && config.build.minify === 'esbuild' |
| 541 | ? [buildEsbuildPlugin()] |
| 542 | : []), |
| 543 | ...(isBuild ? [terserPlugin(config)] : []), |
| 544 | ...(isBuild && !config.isWorker |
| 545 | ? [ |
| 546 | licensePlugin(), |
| 547 | manifestPlugin(), |
| 548 | ssrManifestPlugin(), |
| 549 | buildReporterPlugin(config), |
| 550 | ] |
| 551 | : []), |
| 552 | nativeLoadFallbackPlugin(), |
| 553 | ], |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Bundles a single environment for production. |
nothing calls this directly
no test coverage detected