Skip to content

Commit 79e5f69

Browse files
authored
Merge pull request #1457 from lxKylin/98c9-1
docs: update content
2 parents e6e9263 + 5ae6127 commit 79e5f69

22 files changed

Lines changed: 303 additions & 620 deletions

.vitepress/config.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,6 @@ export default defineConfig({
287287
link: '/guide/performance'
288288
},
289289
{
290-
<<<<<<< HEAD
291-
text: 'Rolldown',
292-
link: '/guide/rolldown'
293-
},
294-
{
295-
=======
296-
>>>>>>> 9d1e98c998121f033ff1f30dbc9a68b8b6603763
297290
text: `Migration from v${viteMajorVersion - 1}`,
298291
link: '/guide/migration'
299292
},

blog/announcing-vite8-beta.md

Lines changed: 53 additions & 53 deletions
Large diffs are not rendered by default.

config/build-options.md

Lines changed: 22 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,13 @@
88
- **默认:** `'baseline-widely-available'`
99
- **相关内容:** [浏览器兼容性](/guide/build#browser-compatibility)
1010

11-
<<<<<<< HEAD
12-
最终软件包的浏览器兼容性目标。默认值是 Vite 的一个特殊值 `'baseline-widely-available'`,该值针对的是包含在 2025 年 5 月 1 日广泛可用的 [Baseline](https://web-platform-dx.github.io/web-features/) 中的浏览器。具体来说,它是 `['chrome107', 'edge107', 'firefox104', 'safari16']`
13-
=======
14-
Browser compatibility target for the final bundle. The default value is a Vite special value, `'baseline-widely-available'`, which targets browsers that are included in the [Baseline](https://web-platform-dx.github.io/web-features/) Widely Available on 2026-01-01. Specifically, it is `['chrome111', 'edge111', 'firefox114', 'safari16.4']`.
15-
>>>>>>> 9d1e98c998121f033ff1f30dbc9a68b8b6603763
11+
最终软件包的浏览器兼容性目标。默认值是 Vite 的一个特殊值 `'baseline-widely-available'`,该值针对的是包含在 2026 年 1 月 1 日广泛可用的 [Baseline](https://web-platform-dx.github.io/web-features/) 中的浏览器。具体来说,它是 `['chrome111', 'edge111', 'firefox114', 'safari16.4']`
1612

1713
另一个特殊值是 `'esnext'` —— 即假设有原生动态导入支持,并只执行最低限度的转译。
1814

19-
<<<<<<< HEAD
20-
转换过程将会由 esbuild 执行,并且此值应该是一个合法的 [esbuild 目标选项](https://esbuild.github.io/api/#target)。自定义目标也可以是一个 ES 版本(例如:`es2015`)、一个浏览器版本(例如:`chrome58`)或是多个目标组成的一个数组。
15+
转换过程将会由 Oxc Transformer 执行,并且此值应该是一个合法的 [Oxc Transformer 目标选项](https://oxc.rs/docs/guide/usage/transformer/lowering#target)。自定义目标也可以是一个 ES 版本(例如:`es2015`)、一个浏览器版本(例如:`chrome58`)或是多个目标组成的一个数组。
2116

22-
注意:如果代码包含不能被 `esbuild` 安全地编译的特性,那么构建将会失败。查看 [esbuild 文档](https://esbuild.github.io/content-types/#javascript) 获取更多细节。
23-
=======
24-
The transform is performed with Oxc Transformer and the value should be a valid [Oxc Transformer target option](https://oxc.rs/docs/guide/usage/transformer/lowering#target). Custom targets can either be an ES version (e.g. `es2015`), a browser with version (e.g. `chrome58`), or an array of multiple target strings.
25-
26-
Note the build will output a warning if the code contains features that cannot be safely transpiled by Oxc. See [Oxc docs](https://oxc.rs/docs/guide/usage/transformer/lowering#warnings) for more details.
27-
>>>>>>> 9d1e98c998121f033ff1f30dbc9a68b8b6603763
17+
注意:如果代码包含不能被 `Oxc` 安全地编译的特性,那么构建将会输出警告。查看 [Oxc 文档](https://oxc.rs/docs/guide/usage/transformer/lowering#warnings) 获取更多细节。
2818

2919
## build.modulePreload {#build-modulepreload}
3020

@@ -139,23 +129,16 @@ Git LFS 占位符会自动排除在内联之外,因为它们不包含其所表
139129

140130
## build.cssMinify {#build-cssminify}
141131

142-
<<<<<<< HEAD
143-
- **类型:** `boolean | 'esbuild' | 'lightningcss'`
144-
- **默认:** 对于客户端,与 [`build.minify`](#build-minify) 相同;对于 SSR,为 `'esbuild'`
145-
146-
此选项允许用户覆盖 CSS 最小化压缩的配置,而不是使用默认的 `build.minify`,这样你就可以单独配置 JS 和 CSS 的最小化压缩方式。Vite 默认使用 `esbuild` 来最小化 CSS。将此选项设置为 `'lightningcss'` 可以改用 [Lightning CSS](https://lightningcss.dev/minification.html) 进行压缩。设置为该项,便可以使用 [`css.lightningcss`](./shared-options.md#css-lightningcss) 选项来进行配置。
147-
=======
148-
- **Type:** `boolean | 'lightningcss' | 'esbuild'`
149-
- **Default:** the same as [`build.minify`](#build-minify) for client, `'lightningcss'` for SSR
132+
- **类型:** `boolean | 'lightningcss' | 'esbuild'`
133+
- **默认:** 对于客户端,与 [`build.minify`](#build-minify) 相同;对于 SSR,为 `'lightningcss'`
150134

151-
This option allows users to override CSS minification specifically instead of defaulting to `build.minify`, so you can configure minification for JS and CSS separately. Vite uses [Lightning CSS](https://lightningcss.dev/minification.html) by default to minify CSS. It can be configured using [`css.lightningcss`](./shared-options.md#css-lightningcss). Set the option to `'esbuild'` to use esbuild instead.
135+
此选项允许用户覆盖 CSS 最小化压缩的配置,而不是使用默认的 `build.minify`,这样你就可以单独配置 JS CSS 的最小压缩方式。Vite 默认使用 [Lightning CSS](https://lightningcss.dev/minification.html) 来压缩 CSS。可以通过 [`css.lightningcss`](./shared-options.md#css-lightningcss) 进行配置。将此选项设置为 `'esbuild'` 可以改用 esbuild 进行压缩。
152136

153-
esbuild must be installed when it is set to `'esbuild'`.
137+
当设置为 `'esbuild'` 时,必须安装 esbuild。
154138

155139
```sh
156140
npm add -D esbuild
157141
```
158-
>>>>>>> 9d1e98c998121f033ff1f30dbc9a68b8b6603763
159142

160143
## build.sourcemap {#build-sourcemap}
161144

@@ -164,34 +147,20 @@ npm add -D esbuild
164147

165148
构建后是否生成 source map 文件。如果为 `true`,将会创建一个独立的 source map 文件。如果为 `'inline'`,source map 将作为一个 data URI 附加在输出文件中。`'hidden'` 的工作原理与 `true` 相似,只是 bundle 文件中相应的注释将不被保留。
166149

167-
<<<<<<< HEAD
168-
## build.rollupOptions {#build-rollupoptions}
169-
170-
- **类型:** [`RollupOptions`](https://cn.rollupjs.org/configuration-options/)
171-
172-
自定义底层的 Rollup 打包配置。这与从 Rollup 配置文件导出的选项相同,并将与 Vite 的内部 Rollup 选项合并。查看 [Rollup 选项文档](https://cn.rollupjs.org/configuration-options/) 获取更多细节。
173-
174-
## build.commonjsOptions {#build-commonjsoptions}
175-
176-
- **类型:** [`RollupCommonJSOptions`](https://github.com/rollup/plugins/tree/master/packages/commonjs#options)
150+
## build.rolldownOptions {#build-rolldownoptions}
177151

178-
传递给 [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/master/packages/commonjs) 插件的选项。
179-
=======
180-
## build.rolldownOptions
181-
182-
- **Type:** [`RolldownOptions`](https://rollupjs.org/configuration-options/)
152+
- **类型:** [`RolldownOptions`](https://rollupjs.org/configuration-options/)
183153

184154
<!-- TODO: update the link above and below to Rolldown's documentation -->
185155

186-
Directly customize the underlying Rolldown bundle. This is the same as options that can be exported from a Rolldown config file and will be merged with Vite's internal Rolldown options. See [Rolldown options docs](https://rollupjs.org/configuration-options/) for more details.
156+
自定义底层的 Rolldown 打包配置。这与从 Rolldown 配置文件导出的选项相同,并将与 Vite 的内部 Rolldown 选项合并。查看 [Rolldown 选项文档](https://cn.rollupjs.org/configuration-options/) 获取更多细节。
187157

188-
## build.rollupOptions
158+
## build.rollupOptions {#build-rollupoptions}
189159

190-
- **Type:** `RolldownOptions`
191-
- **Deprecated**
160+
- **类型:** `RolldownOptions`
161+
- **已弃用**
192162

193-
This option is an alias of `build.rolldownOptions` option. Use `build.rolldownOptions` option instead.
194-
>>>>>>> 9d1e98c998121f033ff1f30dbc9a68b8b6603763
163+
此选项是 `build.rolldownOptions` 选项的别名。请使用 `build.rolldownOptions` 选项代替。
195164

196165
## build.dynamicImportVarsOptions {#build-dynamicimportvarsoptions}
197166

@@ -200,13 +169,9 @@ This option is an alias of `build.rolldownOptions` option. Use `build.rolldownOp
200169

201170
传递给 [@rollup/plugin-dynamic-import-vars](https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars) 的选项。
202171

203-
<<<<<<< HEAD
204-
## build.lib {#build-lib}
205-
=======
206172
<!-- TODO: we need to have a more detailed explanation here as we no longer use @rollup/plugin-dynamic-import-vars. we should say it's compatible with it though -->
207173

208-
## build.lib
209-
>>>>>>> 9d1e98c998121f033ff1f30dbc9a68b8b6603763
174+
## build.lib {#build-lib}
210175

211176
- **类型:** `{ entry: string | string[] | { [entryAlias: string]: string }, name?: string, formats?: ('es' | 'cjs' | 'umd' | 'iife')[], fileName?: string | ((format: ModuleFormat, entryName: string) => string), cssFileName?: string }`
212177
- **相关内容:** [库模式](/guide/build#library-mode)
@@ -302,27 +267,16 @@ export default defineConfig({
302267

303268
## build.minify {#build-minify}
304269

305-
<<<<<<< HEAD
306-
- **类型:** `boolean | 'terser' | 'esbuild'`
307-
- **默认:** 客户端构建默认为`'esbuild'`,SSR构建默认为 `false`
270+
- **类型:** `boolean | 'oxc' | 'terser' | 'esbuild'`
271+
- **默认:** 客户端构建默认为`'oxc'`,SSR构建默认为 `false`
308272

309-
设置为 `false` 可以禁用最小化混淆,或是用来指定使用哪种混淆器。默认为 [Esbuild](https://github.com/evanw/esbuild),它比 terser 快 20-40 倍,压缩率只差 1%-2%。[Benchmarks](https://github.com/privatenumber/minification-benchmarks)
310-
=======
311-
- **Type:** `boolean | 'oxc' | 'terser' | 'esbuild'`
312-
- **Default:** `'oxc'` for client build, `false` for SSR build
273+
设置为 `false` 可以禁用最小化混淆,或是用来指定使用哪种混淆器。默认使用 [Oxc Minifier](https://oxc.rs/docs/guide/usage/minifier),它比 terser 快 30~90 倍,但压缩率仅差 0.5~2%。[基准测试](https://github.com/privatenumber/minification-benchmarks)
313274

314-
Set to `false` to disable minification, or specify the minifier to use. The default is [Oxc Minifier](https://oxc.rs/docs/guide/usage/minifier) which is 30 ~ 90x faster than terser and only 0.5 ~ 2% worse compression. [Benchmarks](https://github.com/privatenumber/minification-benchmarks)
315-
316-
`build.minify: 'esbuild'` is deprecated and will be removed in the future.
317-
>>>>>>> 9d1e98c998121f033ff1f30dbc9a68b8b6603763
275+
`build.minify: 'esbuild'` 已弃用,将在未来版本中移除。
318276

319277
注意,在 lib 模式下使用 `'es'` 时,`build.minify` 选项不会缩减空格,因为会移除掉 pure 标注,导致破坏 tree-shaking。
320278

321-
<<<<<<< HEAD
322-
当设置为 `'terser'` 时必须先安装 Terser。
323-
=======
324-
esbuild or Terser must be installed when it is set to `'esbuild'` or `'terser'` respectively.
325-
>>>>>>> 9d1e98c998121f033ff1f30dbc9a68b8b6603763
279+
当设置为 `'esbuild'``'terser'` 时,必须分别安装 esbuild 或 Terser。
326280

327281
```sh
328282
npm add -D esbuild
@@ -374,15 +328,10 @@ npm add -D terser
374328

375329
## build.watch {#build-watch}
376330

377-
<<<<<<< HEAD
378-
- **类型:** [`WatcherOptions`](https://cn.rollupjs.org/configuration-options/#watch)`| null`
379-
- **默认:** `null`
380-
=======
381331
<!-- TODO: update the link below to Rolldown's documentation -->
382332

383-
- **Type:** [`WatcherOptions`](https://rollupjs.org/configuration-options/#watch)`| null`
384-
- **Default:** `null`
385-
>>>>>>> 9d1e98c998121f033ff1f30dbc9a68b8b6603763
333+
- **类型:** [`WatcherOptions`](https://rollupjs.org/configuration-options/#watch)`| null`
334+
- **默认:** `null`
386335

387336
设置为 `{}` 则会启用 rollup 的监听器。对于只在构建阶段或者集成流程使用的插件很常用。
388337

config/dep-optimization-options.md

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,9 @@ export default defineConfig({
5151
})
5252
```
5353

54-
<<<<<<< HEAD
55-
## optimizeDeps.esbuildOptions <NonInheritBadge /> {#optimizedeps-esbuildoptions}
56-
=======
57-
## optimizeDeps.rolldownOptions <NonInheritBadge />
54+
## optimizeDeps.rolldownOptions <NonInheritBadge /> {#optimizedeps-rolldownoptions}
5855

59-
- **Type:** [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)`<``RolldownOptions`, `'input' | 'logLevel' | 'output'> & {
56+
- **类型:** [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)`<``RolldownOptions`, `'input' | 'logLevel' | 'output'> & {
6057
output?: [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)`<`
6158
`RolldownOutputOptions`,
6259
`'format' | 'sourcemap' | 'dir' | 'banner'>`
@@ -65,14 +62,13 @@ export default defineConfig({
6562
<!-- TODO: add link to RolldownOptions -->
6663
<!-- TODO: add link to RolldownOutputOptions -->
6764

68-
Options to pass to Rolldown during the dep scanning and optimization.
65+
在依赖扫描和优化过程中传递给 Rolldown 的选项。
6966

70-
Certain options are omitted since changing them would not be compatible with Vite's dep optimization.
67+
某些选项进行了省略,因为修改它们与 Vite 的优化方案并不兼容。
7168

72-
- `plugins` are merged with Vite's dep plugin
69+
- `plugins` Vitedep 插件合并
7370

74-
## optimizeDeps.esbuildOptions <NonInheritBadge />
75-
>>>>>>> 9d1e98c998121f033ff1f30dbc9a68b8b6603763
71+
## optimizeDeps.esbuildOptions <NonInheritBadge /> {#optimizedeps-esbuildoptions}
7672

7773
- **类型:** [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)`<`[`EsbuildBuildOptions`](https://esbuild.github.io/api/#general-options)`,
7874
| 'bundle'
@@ -85,18 +81,9 @@ Certain options are omitted since changing them would not be compatible with Vit
8581
| 'outbase'
8682
| 'outExtension'
8783
| 'metafile'>`
88-
- **Deprecated**
84+
- **已弃用**
8985

90-
<<<<<<< HEAD
91-
在依赖扫描和优化过程中传递给 esbuild 的选项。
92-
93-
某些选项进行了省略,因为修改它们与 Vite 的优化方案并不兼容。
94-
95-
- 忽略了 `external` 选项,请使用 Vite 的 `optimizeDeps.exclude` 选项
96-
- `plugins` 与 Vite 的 dep 插件合并
97-
=======
98-
This option is converted to `optimizeDeps.rolldownOptions` internally. Use `optimizeDeps.rolldownOptions` instead.
99-
>>>>>>> 9d1e98c998121f033ff1f30dbc9a68b8b6603763
86+
此选项在内部被转换为 `optimizeDeps.rolldownOptions`。请使用 `optimizeDeps.rolldownOptions` 代替。
10087

10188
## optimizeDeps.force <NonInheritBadge /> {#optimizedeps-force}
10289

config/index.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,8 @@ export default {
2222
vite --config my-config.js
2323
```
2424

25-
<<<<<<< HEAD
2625
::: tip 加载配置文件
27-
默认情况下,Vite 使用 `esbuild` 将配置文件打包到临时文件中并加载它。这可能会在 monorepo 中导入 TypeScript 文件时引发问题。如果你遇到了这种方法问题,可以通过指定 `--configLoader runner` 以改用 [module runner](/guide/api-environment-runtimes.html#modulerunner),它不会创建临时配置并将动态转换任何文件。请注意,module runner 不支持配置文件中的 CJS,但外部 CJS 包应该可以正常工作。
28-
=======
29-
::: tip CONFIG LOADING
30-
By default, Vite uses [Rolldown](https://rolldown.rs/) to bundle the config into a temporary file and load it. This may cause issues when importing TypeScript files in a monorepo. If you encounter any issues with this approach, you can specify `--configLoader runner` to use the [module runner](/guide/api-environment-runtimes.html#modulerunner) instead, which will not create a temporary config and will transform any files on the fly. Note that module runner doesn't support CJS in config files, but external CJS packages should work as usual.
31-
>>>>>>> 9d1e98c998121f033ff1f30dbc9a68b8b6603763
26+
默认情况下,Vite 使用 [Rolldown](https://rolldown.rs/) 将配置文件打包到临时文件中并加载它。这可能会在 monorepo 中导入 TypeScript 文件时引发问题。如果你遇到了这种方法问题,可以通过指定 `--configLoader runner` 以改用 [module runner](/guide/api-environment-runtimes.html#modulerunner),它不会创建临时配置并将动态转换任何文件。请注意,module runner 不支持配置文件中的 CJS,但外部 CJS 包应该可以正常工作。
3227

3328
另外,如果你正在使用支持TypeScript的环境(例如 `node --experimental-strip-types`),或者只编写纯 JavaScript 代码,你可以指定 `--configLoader native` 以使用环境的本机运行时加载配置文件。请注意,配置文件导入的模块的更新不会被检测到,因此不会自动重启 Vite 服务器。
3429
:::

0 commit comments

Comments
 (0)