Skip to content

Commit

Permalink
fix!: default build.cssMinify to 'esbuild' for SSR (#15637)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Oct 24, 2024
1 parent 0a4427f commit f1d3bf7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/config/build-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ In this case, you need to set `build.cssTarget` to `chrome61` to prevent vite fr
## build.cssMinify

- **Type:** `boolean | 'esbuild' | 'lightningcss'`
- **Default:** the same as [`build.minify`](#build-minify)
- **Default:** the same as [`build.minify`](#build-minify) for client, `'esbuild'` for SSR

This option allows users to override CSS minification specifically instead of defaulting to `build.minify`, so you can configure minification for JS and CSS separately. Vite uses `esbuild` by default to minify CSS. Set the option to `'lightningcss'` to use [Lightning CSS](https://lightningcss.dev/minification.html) instead. If selected, it can be configured using [`css.lightningcss`](./shared-options.md#css-lightningcss).

Expand Down
2 changes: 2 additions & 0 deletions docs/guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Vite 6 also introduces a new default value for `json.stringify` which is `'auto'

There are other breaking changes which only affect few users.

- [[#15637] fix!: default `build.cssMinify` to `'esbuild'` for SSR](https://github.com/vitejs/vite/pull/15637)
- [`build.cssMinify`](/config/build-options#build-cssminify) is now enabled by default even for SSR builds.
- [[#18209] refactor!: bump minimal terser version to 5.16.0](https://github.com/vitejs/vite/pull/18209)
- Minimal supported terser version for [`build.minify: 'terser'`](/config/build-options#build-minify) was bumped to 5.16.0 from 5.4.0.
- [[#18243] chore(deps)!: migrate `fast-glob` to `tinyglobby`](https://github.com/vitejs/vite/pull/18243)
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export function resolveBuildEnvironmentOptions(
cssCodeSplit: !raw.lib,
sourcemap: false,
rollupOptions: {},
minify: raw.ssr ? false : 'esbuild',
minify: consumer === 'server' ? false : 'esbuild',
terserOptions: {},
write: true,
emptyOutDir: null,
Expand Down Expand Up @@ -434,7 +434,7 @@ export function resolveBuildEnvironmentOptions(
}

if (resolved.cssMinify == null) {
resolved.cssMinify = !!resolved.minify
resolved.cssMinify = consumer === 'server' ? 'esbuild' : !!resolved.minify
}

return resolved
Expand Down

0 comments on commit f1d3bf7

Please sign in to comment.