From b28049fd5ad1988539d39693c1c96faba9f86478 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Fri, 2 May 2025 18:24:09 +0900 Subject: [PATCH 1/2] feat: stabilize `css.preprocessorMaxWorkers` and default to `true` --- docs/config/shared-options.md | 7 ++++--- packages/vite/src/node/plugins/css.ts | 6 ++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/config/shared-options.md b/docs/config/shared-options.md index 592818c13c0126..7742c47b0b83da 100644 --- a/docs/config/shared-options.md +++ b/docs/config/shared-options.md @@ -280,11 +280,12 @@ export default defineConfig({ ## css.preprocessorMaxWorkers -- **Experimental:** [Give Feedback](https://github.com/vitejs/vite/discussions/15835) - **Type:** `number | true` -- **Default:** `0` (does not create any workers and run in the main thread) +- **Default:** `true` + +Specifies how many threads CSS preprocessors will run on. `true` means the number of CPUs minus 1. When set to `0`, Vite will not create any workers and run the preprocessors in the main thread. -If this option is set, CSS preprocessors will run in workers when possible. `true` means the number of CPUs minus 1. +Depending on the preprocessor options, Vite may run the preprocessors on the main thread even if this option is not set to `0`. ## css.devSourcemap diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index f3c4d1ec512775..75146c2c3f1459 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -144,8 +144,7 @@ export interface CSSOptions { * If this option is set, preprocessors will run in workers when possible. * `true` means the number of CPUs minus 1. * - * @default 0 - * @experimental + * @default true */ preprocessorMaxWorkers?: number | true postcss?: @@ -199,8 +198,7 @@ export const cssConfigDefaults = Object.freeze({ transformer: 'postcss', // modules // preprocessorOptions - /** @experimental */ - preprocessorMaxWorkers: 0, + preprocessorMaxWorkers: true, // postcss /** @experimental */ devSourcemap: false, From 475999ea68e44f252cde324fc149972cd757bdba Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Wed, 28 May 2025 21:27:17 +0900 Subject: [PATCH 2/2] docs: tweak --- docs/config/shared-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config/shared-options.md b/docs/config/shared-options.md index 7742c47b0b83da..25856999b62408 100644 --- a/docs/config/shared-options.md +++ b/docs/config/shared-options.md @@ -283,7 +283,7 @@ export default defineConfig({ - **Type:** `number | true` - **Default:** `true` -Specifies how many threads CSS preprocessors will run on. `true` means the number of CPUs minus 1. When set to `0`, Vite will not create any workers and run the preprocessors in the main thread. +Specifies the maximum number of threads CSS preprocessors can use. `true` means up to the number of CPUs minus 1. When set to `0`, Vite will not create any workers and will run the preprocessors in the main thread. Depending on the preprocessor options, Vite may run the preprocessors on the main thread even if this option is not set to `0`.