Skip to content

Commit acd795f

Browse files
authored
perf: use thread for preprocessors (#13584)
1 parent f6cf3d1 commit acd795f

File tree

7 files changed

+674
-363
lines changed

7 files changed

+674
-363
lines changed

docs/config/shared-options.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,12 @@ Specify options to pass to CSS pre-processors. The file extensions are used as k
222222
- `less` - [Options](https://lesscss.org/usage/#less-options).
223223
- `styl`/`stylus` - Only [`define`](https://stylus-lang.com/docs/js.html#define-name-node) is supported, which can be passed as an object.
224224

225-
All preprocessor options also support the `additionalData` option, which can be used to inject extra code for each style content. Note that if you include actual styles and not just variables, those styles will be duplicated in the final bundle.
226-
227-
Example:
225+
**Example:**
228226

229227
```js
230228
export default defineConfig({
231229
css: {
232230
preprocessorOptions: {
233-
scss: {
234-
additionalData: `$injectedColor: orange;`,
235-
},
236231
less: {
237232
math: 'parens-division',
238233
},
@@ -246,6 +241,34 @@ export default defineConfig({
246241
})
247242
```
248243

244+
### css.preprocessorOptions[extension].additionalData
245+
246+
- **Type:** `string | ((source: string, filename: string) => (string | { content: string; map?: SourceMap }))`
247+
248+
This option can be used to inject extra code for each style content. Note that if you include actual styles and not just variables, those styles will be duplicated in the final bundle.
249+
250+
**Example:**
251+
252+
```js
253+
export default defineConfig({
254+
css: {
255+
preprocessorOptions: {
256+
scss: {
257+
additionalData: `$injectedColor: orange;`,
258+
},
259+
},
260+
},
261+
})
262+
```
263+
264+
## css.preprocessorMaxWorkers
265+
266+
- **Experimental:** [Give Feedback](TODO: update)
267+
- **Type:** `number | true`
268+
- **Default:** `0` (does not create any workers and run in the main thread)
269+
270+
If this option is set, CSS preprocessors will run in workers when possible. `true` means the number of CPUs minus 1.
271+
249272
## css.devSourcemap
250273

251274
- **Experimental:** [Give Feedback](https://github.com/vitejs/vite/discussions/13845)

packages/vite/LICENSE.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,36 @@ Repository: https://github.com/micromatch/anymatch
679679
680680
---------------------------------------
681681

682+
## artichokie
683+
License: MIT
684+
By: sapphi-red, Evan You
685+
Repository: git+https://github.com/sapphi-red/artichokie.git
686+
687+
> MIT License
688+
>
689+
> Copyright (c) 2020-present, Yuxi (Evan) You
690+
> Copyright (c) 2023-present, sapphi-red
691+
>
692+
> Permission is hereby granted, free of charge, to any person obtaining a copy
693+
> of this software and associated documentation files (the "Software"), to deal
694+
> in the Software without restriction, including without limitation the rights
695+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
696+
> copies of the Software, and to permit persons to whom the Software is
697+
> furnished to do so, subject to the following conditions:
698+
>
699+
> The above copyright notice and this permission notice shall be included in all
700+
> copies or substantial portions of the Software.
701+
>
702+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
703+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
704+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
705+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
706+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
707+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
708+
> SOFTWARE.
709+
710+
---------------------------------------
711+
682712
## astring
683713
License: MIT
684714
By: David Bonnet
@@ -2312,35 +2342,6 @@ Repository: sindresorhus/object-assign
23122342
23132343
---------------------------------------
23142344

2315-
## okie
2316-
License: MIT
2317-
By: Evan You
2318-
Repository: git+https://github.com/yyx990803/okie.git
2319-
2320-
> MIT License
2321-
>
2322-
> Copyright (c) 2020-present, Yuxi (Evan) You
2323-
>
2324-
> Permission is hereby granted, free of charge, to any person obtaining a copy
2325-
> of this software and associated documentation files (the "Software"), to deal
2326-
> in the Software without restriction, including without limitation the rights
2327-
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2328-
> copies of the Software, and to permit persons to whom the Software is
2329-
> furnished to do so, subject to the following conditions:
2330-
>
2331-
> The above copyright notice and this permission notice shall be included in all
2332-
> copies or substantial portions of the Software.
2333-
>
2334-
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2335-
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2336-
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2337-
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2338-
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2339-
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2340-
> SOFTWARE.
2341-
2342-
---------------------------------------
2343-
23442345
## on-finished
23452346
License: MIT
23462347
By: Douglas Christopher Wilson, Jonathan Ong

packages/vite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"@types/pnpapi": "^0.0.5",
9797
"acorn": "^8.11.3",
9898
"acorn-walk": "^8.3.2",
99+
"artichokie": "^0.2.0",
99100
"cac": "^6.7.14",
100101
"chokidar": "^3.5.3",
101102
"connect": "^3.7.0",
@@ -118,7 +119,6 @@
118119
"micromatch": "^4.0.5",
119120
"mlly": "^1.5.0",
120121
"mrmime": "^2.0.0",
121-
"okie": "^1.0.1",
122122
"open": "^8.4.2",
123123
"parse5": "^7.1.2",
124124
"periscopic": "^4.0.2",

0 commit comments

Comments
 (0)