Skip to content

Commit 1af1a1d

Browse files
authored
docs(en): merge docs-cn/sync-docs into docs-cn/dev @ 49751c6
2 parents f03603e + 1835e5c commit 1af1a1d

File tree

4 files changed

+43
-18
lines changed

4 files changed

+43
-18
lines changed

config/index.md

+35-10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ export default {
2323
vite --config my-config.js
2424
```
2525

26+
注意,Vite 会替换 `__filename``__dirname` 以及 `import.meta.url`。如果使用这些名称作为变量名可能会导致代码报错:
27+
28+
```js
29+
const __filename = "value"
30+
// will be transformed to
31+
const "path/vite.config.js" = "value"
32+
```
33+
2634
### 配置智能提示 {#config-intellisense}
2735

2836
因为 Vite 本身附带 Typescript 类型,所以你可以通过 IDE 和 jsdoc 的配合来实现智能提示:
@@ -165,14 +173,14 @@ export default defineConfig(async ({ command, mode }) => {
165173
- **类型:** `string`
166174
- **默认:** `"node_modules/.vite"`
167175
168-
存储缓存文件的目录。此目录下会存储预打包的依赖项或 vite 生成的某些缓存文件,使用缓存可以提高性能。如需重新生成缓存文件,你可以使用 `--force` 命令行选项或手动删除目录。此选项的值可以是文件的绝对路径,也可以是以项目根目录为基准的相对路径。
176+
存储缓存文件的目录。此目录下会存储预打包的依赖项或 vite 生成的某些缓存文件,使用缓存可以提高性能。如需重新生成缓存文件,你可以使用 `--force` 命令行选项或手动删除目录。此选项的值可以是文件的绝对路径,也可以是以项目根目录为基准的相对路径。当没有检测到 package.json 时,则默认为 `.vite`
169177
170178
### resolve.alias {#resolve-alias}
171179
172180
- **类型:**
173-
`Record<string, string> | Array<{ find: string | RegExp, replacement: string }>`
181+
`Record<string, string> | Array<{ find: string | RegExp, replacement: string, customResolver?: ResolverFunction | ResolverObject }>`
174182
175-
将会被传递到 `@rollup/plugin-alias` 作为 [entries 的选项](https://github.com/rollup/plugins/tree/master/packages/alias#entries)。也可以是一个对象,或一个 `{ find, replacement }` 的数组。
183+
将会被传递到 `@rollup/plugin-alias` 作为 [entries 的选项](https://github.com/rollup/plugins/tree/master/packages/alias#entries)。也可以是一个对象,或一个 `{ find, replacement, customResolver }` 的数组。
176184
177185
当使用文件系统路径的别名时,请始终使用绝对路径。相对路径的别名值会原封不动地被使用,因此无法被正常解析。
178186
@@ -782,13 +790,9 @@ export default defineConfig({
782790

783791
设置为 `false` 可以禁用最小化混淆,或是用来指定使用哪种混淆器。默认为 [Esbuild](https://github.com/evanw/esbuild),它比 terser 快 20-40 倍,压缩率只差 1%-2%。[Benchmarks](https://github.com/privatenumber/minification-benchmarks)
784792

785-
<<<<<<< HEAD
786-
### build.terserOptions {#build-terseroptions}
787-
=======
788-
Note the `build.minify` option is not available when using the `'es'` format in lib mode.
793+
注意,在 lib 模式下使用 `'es'` 时,`build.minify` 选项将失效。
789794

790-
### build.terserOptions
791-
>>>>>>> 0ffb78e4881cc92f30ae902a80b579252a7f1a45
795+
### build.terserOptions {#build-terseroptions}
792796

793797
- **类型:** `TerserOptions`
794798

@@ -844,7 +848,7 @@ export default defineConfig({
844848
### preview.port {#preview-port}
845849

846850
- **类型:** `number`
847-
- **默认:** `5000`
851+
- **默认:** `4173`
848852

849853
指定开发服务器端口。注意,如果设置的端口已被使用,Vite 将自动尝试下一个可用端口,所以这可能不是最终监听的服务器端口。
850854

@@ -975,3 +979,24 @@ SSR 选项可能会在未来版本中进行调整。
975979
- **默认:** `node`
976980

977981
SSR 服务器的构建目标。
982+
983+
## Worker 选项 {#worker-options}
984+
985+
### worker.format
986+
987+
- **类型:** `'es' | 'iife'`
988+
- **默认:** `iife`
989+
990+
worker bundle 的输出类型。
991+
992+
### worker.plugins
993+
994+
- **类型:** [`(Plugin | Plugin[])[]`](#plugins)
995+
996+
适用于 worker bundle 的 Vite 插件。
997+
998+
### worker.rollupOptions
999+
1000+
- **类型:** [`RollupOptions`](https://rollupjs.org/guide/en/#big-list-of-options)
1001+
1002+
用于构建 worker bundle 的 Rollup 配置项。

guide/features.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@ document.getElementById('foo').className = applyColor
191191

192192
```bash
193193
# .scss and .sass
194-
npm install -D sass
194+
npm add -D sass
195195

196196
# .less
197-
npm install -D less
197+
npm add -D less
198198

199199
# .styl and .stylus
200-
npm install -D stylus
200+
npm add -D stylus
201201
```
202202

203203
如果是用的是单文件组件,可以通过 `<style lang="sass">`(或其他预处理器)自动开启。

guide/index.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Vite 需要 [Node.js](https://nodejs.org/en/) 版本 >= 12.0.0。然而,有些
4444
使用 NPM:
4545

4646
```bash
47-
$ npm init vite@latest
47+
$ npm create vite@latest
4848
```
4949

5050
使用 Yarn:
@@ -65,10 +65,10 @@ $ pnpm create vite
6565

6666
```bash
6767
# npm 6.x
68-
npm init vite@latest my-vue-app --template vue
68+
npm create vite@latest my-vue-app --template vue
6969

70-
# npm 7+, 需要额外的双横线:
71-
npm init vite@latest my-vue-app -- --template vue
70+
# npm 7+, extra double-dash is needed:
71+
npm create vite@latest my-vue-app -- --template vue
7272

7373
# yarn
7474
yarn create vite my-vue-app --template vue

guide/using-plugins.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Vite 可以使用插件进行扩展,这得益于 Rollup 优秀的插件接口
77
若要使用一个插件,需要将它添加到项目的 `devDependencies` 并在 `vite.config.js` 配置文件中的 `plugins` 数组中引入它。例如,要想为传统浏览器提供支持,可以按下面这样使用官方插件 [@vitejs/plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy)
88

99
```
10-
$ npm i -D @vitejs/plugin-legacy
10+
$ npm add -D @vitejs/plugin-legacy
1111
```
1212

1313
```js

0 commit comments

Comments
 (0)