Skip to content

Vite minification #212

@velialiev

Description

@velialiev

Describe the bug

unplugin-swc disables esbuild when used in Vite.

esbuild will be automatically disabled if you use this plugin.

On the other hand, SWC minification doesn't work in Vite because it already uses esbuild as its minifier.

Use the minify: true option, it only works for Rollup as Vite uses esbuild to minify the code and cannot be changed.

Therefore, both SWC minification and esbuild minification don't work in Vite. Is this the intended behavior? In my minimal reproduction, I demonstrate two builds: one with the default Vite configuration and another with unplugin-swc. Enabling unplugin-swc completely disables minification. The only solution I found is to use Terser, which works correctly because unplugin-swc doesn't affect it's configuration.

Reproduction

https://github.com/velialiev/vite-swc-minification

System Info

System:
    OS: macOS 15.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 72.06 MB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 22.13.1 - ~/.nvm/versions/node/v22.13.1/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v22.13.1/bin/npm
    pnpm: 10.7.0 - ~/Library/pnpm/pnpm
    bun: 1.2.8 - ~/.bun/bin/bun
  Browsers:
    Chrome: 138.0.7204.93
    Safari: 18.2

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions