Skip to content

Commit e9cdfb9

Browse files
authored
docs: add NonInheritBadge to options that are not inherited to other environments (vitejs#20471)
1 parent 61a9778 commit e9cdfb9

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<template>
2+
<a
3+
href="/guide/api-environment#environments-configuration"
4+
class="ignore-header"
5+
>
6+
<Badge type="info" text="non-inherit" />
7+
</a>
8+
</template>

docs/.vitepress/theme/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import AsideSponsors from './components/AsideSponsors.vue'
99
import SvgImage from './components/SvgImage.vue'
1010
import YouTubeVideo from './components/YouTubeVideo.vue'
1111
import SponsorBanner from './components/SponsorBanner.vue'
12+
import NonInheritBadge from './components/NonInheritBadge.vue'
1213
import 'virtual:group-icons.css'
1314

1415
export default {
@@ -22,6 +23,7 @@ export default {
2223
enhanceApp({ app }) {
2324
app.component('SvgImage', SvgImage)
2425
app.component('YouTubeVideo', YouTubeVideo)
26+
app.component('NonInheritBadge', NonInheritBadge)
2527
app.use(TwoslashFloatingVue)
2628
},
2729
} satisfies Theme

docs/config/dep-optimization-options.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
Unless noted, the options in this section are only applied to the dependency optimizer, which is only used in dev.
66

7-
## optimizeDeps.entries
7+
## optimizeDeps.entries <NonInheritBadge />
88

99
- **Type:** `string | string[]`
1010

1111
By default, Vite will crawl all your `.html` files to detect dependencies that need to be pre-bundled (ignoring `node_modules`, `build.outDir`, `__tests__` and `coverage`). If `build.rollupOptions.input` is specified, Vite will crawl those entry points instead.
1212

1313
If neither of these fit your needs, you can specify custom entries using this option - the value should be a [`tinyglobby` pattern](https://github.com/SuperchupuDev/tinyglobby) or array of patterns that are relative from Vite project root. This will overwrite default entries inference. Only `node_modules` and `build.outDir` folders will be ignored by default when `optimizeDeps.entries` is explicitly defined. If other folders need to be ignored, you can use an ignore pattern as part of the entries list, marked with an initial `!`. `node_modules` will not be ignored for patterns that explicitly include the string `node_modules`.
1414

15-
## optimizeDeps.exclude
15+
## optimizeDeps.exclude <NonInheritBadge />
1616

1717
- **Type:** `string[]`
1818

@@ -33,7 +33,7 @@ export default defineConfig({
3333

3434
:::
3535

36-
## optimizeDeps.include
36+
## optimizeDeps.include <NonInheritBadge />
3737

3838
- **Type:** `string[]`
3939

@@ -51,7 +51,7 @@ export default defineConfig({
5151
})
5252
```
5353

54-
## optimizeDeps.esbuildOptions
54+
## optimizeDeps.esbuildOptions <NonInheritBadge />
5555

5656
- **Type:** [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)`<`[`EsbuildBuildOptions`](https://esbuild.github.io/api/#general-options)`,
5757
| 'bundle'
@@ -72,28 +72,28 @@ Certain options are omitted since changing them would not be compatible with Vit
7272
- `external` is also omitted, use Vite's `optimizeDeps.exclude` option
7373
- `plugins` are merged with Vite's dep plugin
7474

75-
## optimizeDeps.force
75+
## optimizeDeps.force <NonInheritBadge />
7676

7777
- **Type:** `boolean`
7878

7979
Set to `true` to force dependency pre-bundling, ignoring previously cached optimized dependencies.
8080

81-
## optimizeDeps.noDiscovery
81+
## optimizeDeps.noDiscovery <NonInheritBadge />
8282

8383
- **Type:** `boolean`
8484
- **Default:** `false`
8585

8686
When set to `true`, automatic dependency discovery will be disabled and only dependencies listed in `optimizeDeps.include` will be optimized. CJS-only dependencies must be present in `optimizeDeps.include` during dev.
8787

88-
## optimizeDeps.holdUntilCrawlEnd
88+
## optimizeDeps.holdUntilCrawlEnd <NonInheritBadge />
8989

9090
- **Experimental:** [Give Feedback](https://github.com/vitejs/vite/discussions/15834)
9191
- **Type:** `boolean`
9292
- **Default:** `true`
9393

9494
When enabled, it will hold the first optimized deps results until all static imports are crawled on cold start. This avoids the need for full-page reloads when new dependencies are discovered and they trigger the generation of new common chunks. If all dependencies are found by the scanner plus the explicitly defined ones in `include`, it is better to disable this option to let the browser process more requests in parallel.
9595

96-
## optimizeDeps.disabled
96+
## optimizeDeps.disabled <NonInheritBadge />
9797

9898
- **Deprecated**
9999
- **Experimental:** [Give Feedback](https://github.com/vitejs/vite/discussions/13839)
@@ -108,7 +108,7 @@ To disable the optimizer completely, use `optimizeDeps.noDiscovery: true` to dis
108108
Optimizing dependencies during build time was an **experimental** feature. Projects trying out this strategy also removed `@rollup/plugin-commonjs` using `build.commonjsOptions: { include: [] }`. If you did so, a warning will guide you to re-enable it to support CJS only packages while bundling.
109109
:::
110110

111-
## optimizeDeps.needsInterop
111+
## optimizeDeps.needsInterop <NonInheritBadge />
112112

113113
- **Experimental**
114114
- **Type:** `string[]`

docs/config/shared-options.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ If you have duplicated copies of the same dependency in your app (likely due to
114114
For SSR builds, deduplication does not work for ESM build outputs configured from `build.rollupOptions.output`. A workaround is to use CJS build outputs until ESM has better plugin support for module loading.
115115
:::
116116
117-
## resolve.conditions
117+
## resolve.conditions <NonInheritBadge />
118118
119119
- **Type:** `string[]`
120120
- **Default:** `['module', 'browser', 'development|production']` (`defaultClientConditions`)
@@ -140,7 +140,7 @@ Here, `import` and `require` are "conditions". Conditions can be nested and shou
140140

141141
Note that `import`, `require`, `default` conditions are always applied if the requirements are met.
142142

143-
## resolve.mainFields
143+
## resolve.mainFields <NonInheritBadge />
144144

145145
- **Type:** `string[]`
146146
- **Default:** `['browser', 'module', 'jsnext:main', 'jsnext']` (`defaultClientMainFields`)

docs/guide/api-environment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default {
7070
}
7171
```
7272

73-
When not explicitly documented, environment inherits the configured top-level config options (for example, the new `server` and `edge` environments will inherit the `build.sourcemap: false` option). A small number of top-level options, like `optimizeDeps`, only apply to the `client` environment, as they don't work well when applied as a default to server environments. The `client` environment can also be configured explicitly through `environments.client`, but we recommend to do it with the top-level options so the client config remains unchanged when adding new environments.
73+
When not explicitly documented, environment inherits the configured top-level config options (for example, the new `server` and `edge` environments will inherit the `build.sourcemap: false` option). A small number of top-level options, like `optimizeDeps`, only apply to the `client` environment, as they don't work well when applied as a default to server environments. Those options have <NonInheritBadge /> badge in [the reference](/config/). The `client` environment can also be configured explicitly through `environments.client`, but we recommend to do it with the top-level options so the client config remains unchanged when adding new environments.
7474

7575
The `EnvironmentOptions` interface exposes all the per-environment options. There are environment options that apply to both `build` and `dev`, like `resolve`. And there are `DevEnvironmentOptions` and `BuildEnvironmentOptions` for dev and build specific options (like `dev.warmup` or `build.outDir`). Some options like `optimizeDeps` only applies to dev, but is kept as top level instead of nested in `dev` for backward compatibility.
7676

0 commit comments

Comments
 (0)