|
6 | 6 | - **默认:** `'modules'` |
7 | 7 | - **相关内容:** [浏览器兼容性](/guide/build#browser-compatibility) |
8 | 8 |
|
9 | | -设置最终构建的浏览器兼容目标。默认值是一个 Vite 特有的值——`'modules'`,这是指 [支持原生 ES 模块](https://caniuse.com/es6-module)、[原生 ESM 动态导入](https://caniuse.com/es6-module-dynamic-import) 和 [`import.meta`](https://caniuse.com/mdn-javascript_operators_import_meta) 的浏览器。 |
| 9 | +设置最终构建的浏览器兼容目标。默认值是一个 Vite 特有的值:'modules'`,这是指 [支持原生 ES 模块](https://caniuse.com/es6-module)、[原生 ESM 动态导入](https://caniuse.com/es6-module-dynamic-import) 和 [`import.meta`](https://caniuse.com/mdn-javascript_operators_import_meta) 的浏览器。Vite 将替换 `modules` 为 `['es2020', 'edge88', 'firefox78', 'chrome87', 'safari14']` |
10 | 10 |
|
11 | 11 | 另一个特殊值是 “esnext” —— 即假设有原生动态导入支持,并且将会转译得尽可能小: |
12 | 12 |
|
|
20 | 20 | ## build.modulePreload {#build-modulepreload} |
21 | 21 |
|
22 | 22 | - **类型:** `boolean | { polyfill?: boolean, resolveDependencies?: ResolveModulePreloadDependenciesFn }` |
23 | | -- **默认值:** `true` |
| 23 | +- **默认值:** `{ polyfill: true }` |
24 | 24 |
|
25 | 25 | 默认情况下,一个 [模块预加载 polyfill](https://guybedford.com/es-module-preloading-integrity#modulepreload-polyfill) 会被自动注入。该 polyfill 会自动注入到每个 `index.html` 入口的的代理模块中。如果构建通过 `build.rollupOptions.input` 被配置为了使用非 HTML 入口的形式,那么必须要在你的自定义入口中手动引入该 polyfill: |
26 | 26 |
|
@@ -126,9 +126,9 @@ Git LFS 占位符会自动排除在内联之外,因为它们不包含它们所 |
126 | 126 |
|
127 | 127 | ## build.rollupOptions {#build-rollupoptions} |
128 | 128 |
|
129 | | -- **类型:** [`RollupOptions`](https://rollupjs.org/guide/en/#big-list-of-options) |
| 129 | +- **类型:** [`RollupOptions`](https://rollupjs.org/configuration-options/) |
130 | 130 |
|
131 | | -自定义底层的 Rollup 打包配置。这与从 Rollup 配置文件导出的选项相同,并将与 Vite 的内部 Rollup 选项合并。查看 [Rollup 选项文档](https://rollupjs.org/guide/en/#big-list-of-options) 获取更多细节。 |
| 131 | +自定义底层的 Rollup 打包配置。这与从 Rollup 配置文件导出的选项相同,并将与 Vite 的内部 Rollup 选项合并。查看 [Rollup 选项文档](https://rollupjs.org/configuration-options/) 获取更多细节。 |
132 | 132 |
|
133 | 133 | ## build.commonjsOptions {#build-commonjsoptions} |
134 | 134 |
|
@@ -169,8 +169,8 @@ Git LFS 占位符会自动排除在内联之外,因为它们不包含它们所 |
169 | 169 | ## build.ssr {#build-ssr} |
170 | 170 |
|
171 | 171 | - **类型:** `boolean | string` |
172 | | -- **默认值:** `undefined` |
173 | | -- **相关链接:** [Server-Side Rendering](/guide/ssr) |
| 172 | +- **默认值:** `false` |
| 173 | +- **相关链接:** [服务端渲染](/guide/ssr) |
174 | 174 |
|
175 | 175 | 生成面向 SSR 的构建。此选项的值可以是字符串,用于直接定义 SSR 的入口,也可以为 `true`,但这需要通过设置 `rollupOptions.input` 来指定 SSR 的入口。 |
176 | 176 |
|
@@ -233,7 +233,7 @@ npm add -D terser |
233 | 233 |
|
234 | 234 | ## build.watch {#build-watch} |
235 | 235 |
|
236 | | -- **类型:** [`WatcherOptions`](https://rollupjs.org/guide/en/#watch-options)`| null` |
| 236 | +- **类型:** [`WatcherOptions`](https://rollupjs.org/configuration-options/#watch)`| null` |
237 | 237 | - **默认:** `null` |
238 | 238 |
|
239 | 239 | 设置为 `{}` 则会启用 rollup 的监听器。对于只在构建阶段或者集成流程使用的插件很常用。 |
|
0 commit comments