@@ -23,6 +23,14 @@ export default {
23
23
vite --config my-config.js
24
24
```
25
25
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
+
26
34
### 配置智能提示 {#config-intellisense}
27
35
28
36
因为 Vite 本身附带 Typescript 类型,所以你可以通过 IDE 和 jsdoc 的配合来实现智能提示:
@@ -165,14 +173,14 @@ export default defineConfig(async ({ command, mode }) => {
165
173
- **类型:** ` string `
166
174
- **默认:** ` " node_modules/.vite" `
167
175
168
- 存储缓存文件的目录。此目录下会存储预打包的依赖项或 vite 生成的某些缓存文件,使用缓存可以提高性能。如需重新生成缓存文件,你可以使用 ` -- force ` 命令行选项或手动删除目录。此选项的值可以是文件的绝对路径,也可以是以项目根目录为基准的相对路径。
176
+ 存储缓存文件的目录。此目录下会存储预打包的依赖项或 vite 生成的某些缓存文件,使用缓存可以提高性能。如需重新生成缓存文件,你可以使用 ` -- force ` 命令行选项或手动删除目录。此选项的值可以是文件的绝对路径,也可以是以项目根目录为基准的相对路径。当没有检测到 package.json 时,则默认为 ` . vite ` 。
169
177
170
178
### resolve.alias {#resolve-alias}
171
179
172
180
- **类型:**
173
- ` Record < string , string > | Array <{ find: string | RegExp , replacement: string }>`
181
+ ` Record < string , string > | Array <{ find: string | RegExp , replacement: string , customResolver ? : ResolverFunction | ResolverObject }>`
174
182
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 }` 的数组。
176
184
177
185
当使用文件系统路径的别名时,请始终使用绝对路径。相对路径的别名值会原封不动地被使用,因此无法被正常解析。
178
186
@@ -782,13 +790,9 @@ export default defineConfig({
782
790
783
791
设置为 ` false ` 可以禁用最小化混淆,或是用来指定使用哪种混淆器。默认为 [ Esbuild] ( https://github.com/evanw/esbuild ) ,它比 terser 快 20-40 倍,压缩率只差 1%-2%。[ Benchmarks] ( https://github.com/privatenumber/minification-benchmarks )
784
792
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 ` 选项将失效。
789
794
790
- ### build.terserOptions
791
- >>>>>>> 0ffb78e4881cc92f30ae902a80b579252a7f1a45
795
+ ### build.terserOptions {#build-terseroptions}
792
796
793
797
- ** 类型:** ` TerserOptions `
794
798
@@ -844,7 +848,7 @@ export default defineConfig({
844
848
### preview.port {#preview-port}
845
849
846
850
- ** 类型:** ` number `
847
- - ** 默认:** ` 5000 `
851
+ - ** 默认:** ` 4173 `
848
852
849
853
指定开发服务器端口。注意,如果设置的端口已被使用,Vite 将自动尝试下一个可用端口,所以这可能不是最终监听的服务器端口。
850
854
@@ -975,3 +979,24 @@ SSR 选项可能会在未来版本中进行调整。
975
979
- ** 默认:** ` node `
976
980
977
981
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 配置项。
0 commit comments