Skip to content

Commit a20a35e

Browse files
docs(build): note cssTarget precedence (#23200)
1 parent d615bcd commit a20a35e

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

docs/config/build-options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ If you specify `build.lib`, `build.cssCodeSplit` will be `false` as default.
123123

124124
This option allows users to set a different browser target for CSS minification from the one used for JavaScript transpilation.
125125

126+
When `build.cssMinify` is `'lightningcss'` (the default), this option takes precedence over [`css.lightningcss.targets`](./shared-options.md#css-lightningcss) for the minification step.
127+
126128
It should only be used when you are targeting a non-mainstream browser.
127129
One example is Android WeChat WebView, which supports most modern JavaScript features but not the [`#RGBA` hexadecimal color notation in CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#rgb_colors).
128130
In this case, you need to set `build.cssTarget` to `chrome61` to prevent vite from transforming `rgba()` colors into `#RGBA` hexadecimal notations.

docs/guide/features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ Vite is pre-configured to support CSS `@import` inlining via `postcss-import`. V
281281

282282
If the project contains valid PostCSS config (any format supported by [postcss-load-config](https://github.com/postcss/postcss-load-config), e.g. `postcss.config.js`), it will be automatically applied to all imported CSS.
283283

284-
Note that CSS minification will run after PostCSS and will use [`build.cssTarget`](/config/build-options.md#build-csstarget) option.
284+
Note that CSS minification will run after PostCSS and will use the [`build.cssTarget`](/config/build-options.md#build-csstarget) option.
285285

286286
### CSS Modules
287287

packages/vite/src/node/build.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ export interface BuildEnvironmentOptions {
157157
* a niche browser that comes with most modern JavaScript features
158158
* but has poor CSS support, e.g. Android WeChat WebView, which
159159
* doesn't support the #RGBA syntax.
160+
* When `build.cssMinify` is `lightningcss` (the default), this
161+
* option takes precedence over `css.lightningcss.targets` for the
162+
* minification step.
160163
* @default target
161164
*/
162165
cssTarget?: EsbuildTarget | false

0 commit comments

Comments
 (0)