File tree 3 files changed +21
-7
lines changed
3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -488,7 +488,7 @@ async function createServer() {
488
488
createServer ()
489
489
```
490
490
491
- ### server.fsServe .strict {#server-fsserve -strict}
491
+ ### server.fs .strict {#server-fs -strict}
492
492
493
493
- ** 实验性**
494
494
- ** 类型:** ` boolean `
@@ -501,7 +501,7 @@ createServer()
501
501
- ** 实验性**
502
502
- ** 类型:** ` string `
503
503
504
- 限制哪些文件可以通过 ` /@fs/ ` 路径提供服务。当 ` server.fsServe.strict ` 设置为 true 时,访问这个目录外的文件将会返回 403 结果。
504
+ 限制哪些文件可以通过 ` /@fs/ ` 路径提供服务。当 ` server.fsServe.strict ` 设置为 true 时,访问这个目录列表外的文件将会返回 403 结果。
505
505
506
506
Vite 将会搜索此根目录下潜在工作空间并作默认使用。一个有效的工作空间应符合以下几个条件,否则会默认以 [ 项目 root 目录] ( /guide/#index-html-and-project-root ) 作备选方案。
507
507
@@ -514,9 +514,11 @@ createServer()
514
514
``` js
515
515
export default {
516
516
server: {
517
- fsServe : {
517
+ fs : {
518
518
// 可以为项目根目录的上一级提供服务
519
- root: ' ..'
519
+ allow: [
520
+ ' ..'
521
+ ]
520
522
}
521
523
}
522
524
}
@@ -698,6 +700,10 @@ createServer()
698
700
699
701
在预构建中强制排除的依赖项。
700
702
703
+ :::warning CommonJS
704
+ CommonJS 的依赖不应该排除在优化外。如果一个 ESM 依赖拥有一个嵌套的 CommonJS 依赖,它也不应被排除。
705
+ :::
706
+
701
707
### optimizeDeps.include {#optimizedeps-include}
702
708
703
709
- ** 类型:** ` string[] `
@@ -729,7 +735,7 @@ SSR 选项可能会在未来版本中进行调整。
729
735
730
736
### ssr.noExternal {#ssr-noexternal}
731
737
732
- - ** 类型:** ` string[] `
738
+ - ** 类型:** ` string | RegExp | (string | RegExp) [] `
733
739
734
740
列出的是防止被 SSR 外部化依赖项。
735
741
Original file line number Diff line number Diff line change @@ -112,4 +112,12 @@ if (import.meta.hot) {
112
112
113
113
## ` hot.on(event, cb)` {#hot-onevent-cb}
114
114
115
- 监听自定义 HMR 事件。自定义 HMR 事件可以由插件发送。更多细节详见 [handleHotUpdate](./api-plugin#handleHotUpdate)。
115
+ 监听自定义 HMR 事件。
116
+
117
+ 以下 HMR 事件由 Vite 自动触发:
118
+ - ` ' vite:beforeUpdate' ` 当更新即将被应用时(例如,一个模块将被替换)
119
+ - ` ' vite:beforeFullReload' ` 当完整的重载即将发生时
120
+ - ` ' vite:beforePrune' ` 当不再需要的模块即将被剔除时
121
+ - ` ' vite:error' ` 当发生错误时(例如,语法错误)
122
+
123
+ 自定义 HMR 事件可以由插件发送。更多细节详见 [handleHotUpdate](./api-plugin#handleHotUpdate)。
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ Falsy 虚值的插件将被忽略,可以用来轻松地启用或停用插件
33
33
Vite 旨在为常见的 Web 开发范式提供开箱即用的支持。在寻找一个 Vite 或兼容的 Rollup 插件之前,请先查看 [ 功能指引] ( ../guide/features.md ) 。大量在 Rollup 项目中需要使用插件的用例在 Vite 中已经覆盖到了。
34
34
:::
35
35
36
- 查看 [ Plugins 章节] ( ../plugins ) 获取官方插件信息。社区插件列表请参见 [ awesome-vite] ( https://github.com/vitejs/awesome-vite#plugins ) 。而对于兼容的 Rollup 插件,请查看 [ Vite Rollup 插件] ( https://vite-rollup-plugins.patak.dev ) 获取一个带使用说明的兼容 Rollup 官方插件列表,若列表中没有找到,则请参阅 [ Rollup 插件兼容性章节] ( ../guide/api-plugin#rollup-plugin-compatibility ) 。
36
+ 查看 [ Plugins 章节] ( ../plugins/ ) 获取官方插件信息。社区插件列表请参见 [ awesome-vite] ( https://github.com/vitejs/awesome-vite#plugins ) 。而对于兼容的 Rollup 插件,请查看 [ Vite Rollup 插件] ( https://vite-rollup-plugins.patak.dev ) 获取一个带使用说明的兼容 Rollup 官方插件列表,若列表中没有找到,则请参阅 [ Rollup 插件兼容性章节] ( ../guide/api-plugin#rollup-plugin-compatibility ) 。
37
37
38
38
你也可以使用此 [ npm Vite 插件搜索链接] ( https://www.npmjs.com/search?q=vite-plugin&ranking=popularity ) 来找到一些遵循了 [ 推荐约定] ( ./api-plugin.md#conventions ) 的 Vite 插件,或者此 [ npm Rollup 插件搜索链接] ( https://www.npmjs.com/search?q=rollup-plugin&ranking=popularity ) 获取 Rollup 插件。
39
39
You can’t perform that action at this time.
0 commit comments