You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/config/index.md
+56-1Lines changed: 56 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -196,14 +196,69 @@ When Vitest encounters the external library listed in `include`, it will be bund
196
196
- Your `alias` configuration is now respected inside bundled packages
197
197
- Code in your tests is running closer to how it's running in the browser
198
198
199
-
Be aware that only packages in `deps.optimizer?.[mode].include` option are bundled (some plugins populate this automatically, like Svelte). You can read more about available options in [Vite](https://vitejs.dev/config/dep-optimization-options.html) docs. By default, Vitest uses `optimizer.web` for `jsdom` and `happy-dom` environments, and `optimizer.ssr` for `node` and `edge` environments, but it is configurable by [`transformMode`](#transformmode).
199
+
Be aware that only packages in `deps.optimizer?.[mode].include` option are bundled (some plugins populate this automatically, like Svelte). You can read more about available options in [Vite](https://vitejs.dev/config/dep-optimization-options.html) docs (Vitest doesn't support `disable` and `noDiscovery` options). By default, Vitest uses `optimizer.web` for `jsdom` and `happy-dom` environments, and `optimizer.ssr` for `node` and `edge` environments, but it is configurable by [`transformMode`](#transformmode).
200
200
201
201
This options also inherits your `optimizeDeps` configuration (for web Vitest will extend `optimizeDeps`, for ssr - `ssr.optimizeDeps`). If you redefine `include`/`exclude` option in `deps.optimizer` it will extend your `optimizeDeps` when running tests. Vitest automatically removes the same options from `include`, if they are listed in `exclude`.
202
202
203
203
::: tip
204
204
You will not be able to edit your `node_modules` code for debugging, since the code is actually located in your `cacheDir` or `test.cache.dir` directory. If you want to debug with `console.log` statements, edit it directly or force rebundling with `deps.optimizer?.[mode].force` option.
205
205
:::
206
206
207
+
#### deps.optimizer.{mode}.enabled
208
+
209
+
-**Type:**`boolean`
210
+
-**Default:**`true`
211
+
212
+
Enable dependency optimization.
213
+
214
+
#### deps.web
215
+
216
+
-**Type:**`{ transformAssets?, ... }`
217
+
-**Version:** Since Vite 0.34.2
218
+
219
+
Options that are applied to external files when transform mode is set to `web`. By default, `jsdom` and `happy-dom` use `web` mode, while `node` and `edge` environments use `ssr` transform mode, so these options will have no affect on files inside those environments.
220
+
221
+
Usually, files inside `node_modules` are externalized, but these options also affect files in [`server.deps.external`](#server-deps-external).
222
+
223
+
#### deps.web.transformAssets
224
+
225
+
-**Type:**`boolean`
226
+
-**Default:**`true`
227
+
228
+
Should Vitest process assets (.png, .svg, .jpg, etc) files and resolve them like Vite does in the browser.
229
+
230
+
hese module will have a default export equal to the path to the asset, if no query is specified.
231
+
232
+
::: warning
233
+
At the moment, this option only works with [`experimentalVmThreads`](#experimentalvmthreads) pool.
234
+
:::
235
+
236
+
#### deps.web.transformCss
237
+
238
+
-**Type:**`boolean`
239
+
-**Default:**`true`
240
+
241
+
Should Vitest process CSS (.css, .scss, .sass, etc) files and resolve them like Vite does in the browser.
242
+
243
+
If CSS files are disabled with [`css`](#css) options, this option will just silence `UNKNOWN_EXTENSION` errors.
244
+
245
+
::: warning
246
+
At the moment, this option only works with [`experimentalVmThreads`](#experimentalvmthreads) pool.
247
+
:::
248
+
249
+
#### deps.web.transformGlobPattern
250
+
251
+
-**Type:**`RegExp | RegExp[]`
252
+
-**Default:**`[]`
253
+
254
+
Regexp pattern to match external files that should be transformed.
255
+
256
+
By default, files inside `node_modules` are externalized and not transformed, unless it's CSS or an asset, and corresponding option is not disabled.
257
+
258
+
::: warning
259
+
At the moment, this option only works with [`experimentalVmThreads`](#experimentalvmthreads) pool.
0 commit comments