Skip to content

Commit 05dec93

Browse files
authored
release: v2.5.10
2 parents 3279fa7 + 0105efb commit 05dec93

File tree

8 files changed

+63
-12
lines changed

8 files changed

+63
-12
lines changed

.vitepress/theme/custom.css

+11
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,21 @@
2929
--docsearch-primary-color: var(--c-brand) !important;
3030
}
3131

32+
#play-vite-audio {
33+
padding: 0;
34+
margin-left: 5px;
35+
display: inline-flex;
36+
}
37+
38+
#play-vite-audio img {
39+
opacity: 0.8;
40+
}
41+
3242
/* docs-cn specific */
3343
.cn-footnote {
3444
margin-top: 20px;
3545
}
46+
3647
.cn-footnote .title {
3748
display: block;
3849
margin-bottom: 10px;

config/index.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,22 @@ export default defineConfig(async ({ command, mode }) => {
311311
- **类型:** `string | RegExp | (string | RegExp)[]`
312312
- **相关内容:** [静态资源处理](/guide/assets)
313313

314-
指定其他文件类型作为静态资源处理,因此:
314+
指定额外的 [picomatch 模式](https://github.com/micromatch/picomatch) 作为静态资源处理,因此:
315315

316316
- 当从 HTML 引用它们或直接通过 `fetch` 或 XHR 请求它们时,它们将被插件转换管道排除在外。
317317

318318
- 从 JavaScript 导入它们将返回解析后的 URL 字符串(如果你设置了 `enforce: 'pre'` 插件来处理不同的资产类型,这可能会被覆盖)。
319319

320320
内建支持的资源类型列表可以在 [这里](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/constants.ts) 找到。
321321

322+
**示例:**
323+
324+
```js
325+
export default defineConfig({
326+
assetsInclude: ['**/*.gltf']
327+
})
328+
```
329+
322330
### logLevel {#loglevel}
323331

324332
- **类型:** `'info' | 'warn' | 'error' | 'silent'`
@@ -654,6 +662,14 @@ createServer()
654662

655663
当设置为 `true`,构建后将会生成 `manifest.json` 文件,包含了没有被 hash 的资源文件名和 hash 后版本的映射。可以为一些服务器框架渲染时提供正确的资源引入链接。
656664

665+
### build.ssrManifest {#build-ssrmanifest}
666+
667+
- **类型:** `boolean`
668+
- **默认值:** `false`
669+
- **相关链接:** [Server-Side Rendering](/guide/ssr)
670+
671+
当设置为 `true` 时,构建也将生成 SSR 的 manifest 文件,以确定生产中的样式链接与资产预加载指令。
672+
657673
### build.minify {#build-minify}
658674

659675
- **类型:** `boolean | 'terser' | 'esbuild'`

guide/api-javascript.md

+13-10
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,6 @@ interface ViteDevServer {
8585
* 应用 Vite 内建 HTML 转换和任意插件 HTML 转换
8686
*/
8787
transformIndexHtml(url: string, html: string): Promise<string>
88-
/**
89-
* 使用 esbuild 转换一个文件的工具函数
90-
* 对某些特定插件十分有用
91-
*/
92-
transformWithEsbuild(
93-
code: string,
94-
filename: string,
95-
options?: EsbuildTransformOptions,
96-
inMap?: object
97-
): Promise<ESBuildTransformResult>
9888
/**
9989
* 加载一个给定的 URL 作为 SSR 的实例化模块
10090
*/
@@ -157,3 +147,16 @@ async function resolveConfig(
157147
defaultMode?: string
158148
): Promise<ResolvedConfig>
159149
```
150+
151+
## `transformWithEsbuild`
152+
153+
**类型签名:**
154+
155+
```ts
156+
async function transformWithEsbuild(
157+
code: string,
158+
filename: string,
159+
options?: EsbuildTransformOptions,
160+
inMap?: object
161+
): Promise<ESBuildTransformResult>
162+
```

guide/api-plugin.md

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ Vite 插件扩展了设计出色的 Rollup 接口,带有一些 Vite 独有的
44

55
**推荐在阅读下面的章节之前,首先阅读下 [Rollup 插件文档](https://rollupjs.org/guide/en/#plugin-development)**
66

7+
## 致插件创作者 {#authoring-a-plugin}
8+
9+
Vite 努力秉承开箱即用的原则,因此在创作一款新插件前,请确保已经阅读过 [Vite 的功能指南](/guide/features),避免重复劳作。同时还应查看社区是否存在可用插件,包括 [兼容 Rollup 的插件](https://github.com/rollup/awesome) 以及 [Vite 的专属插件](https://github.com/vitejs/awesome-vite#plugins)
10+
11+
当创作插件时,你可以在 `vite.config.js` 中直接使用它。没必要直接为它创建一个新的 package。当你发现某个插件在你项目中很有用时,可以考虑,可以考虑 [在社区中](https://chat.vitejs.dev) 将其与他人分享。
12+
13+
::: tip
14+
在学习、调试或创作插件时,我们建议在你的项目中引入 [vite-plugin-inspect](https://github.com/antfu/vite-plugin-inspect)。 它可以帮助你检查 Vite 插件的中间状态。安装后,你可以访问 `localhost:3000/__inspect/` 来检查你项目的模块和栈信息。请查阅 [vite-plugin-inspect 文档](https://github.com/antfu/vite-plugin-inspect) 中的安装说明。
15+
![vite-plugin-inspect](/images/vite-plugin-inspect.png)
16+
:::
17+
718
## 约定 {#conventions}
819

920
如果插件不使用 Vite 特有的钩子,可以实现为 [兼容的 Rollup 插件](#rollup-plugin-compatibility),推荐使用 [Rollup 插件名称约定](https://rollupjs.org/guide/en/#conventions)

guide/index.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# 开始 {#getting-started}
22

3+
<audio id="vite-audio">
4+
<source src="/vite.mp3" type="audio/mpeg">
5+
</audio>
6+
37
## 总览 {#overview}
48

5-
Vite (法语意为 "快速的",发音 `/vit/`) 是一种新型前端构建工具,能够显著提升前端开发体验。它主要由两部分组成:
9+
Vite (法语意为 "快速的",发音 `/vit/`<button id="play-vite-audio" onclick="document.getElementById('vite-audio').play();"><img src="/voice.svg" height="15"></button>) 是一种新型前端构建工具,能够显著提升前端开发体验。它主要由两部分组成:
610

711
- 一个开发服务器,它基于 [原生 ES 模块](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) 提供了 [丰富的内建功能](./features),如速度快到惊人的 [模块热更新(HMR)](./features#hot-module-replacement)
812

images/vite-plugin-inspect.png

2.17 MB
Loading

public/vite.mp3

3 KB
Binary file not shown.

public/voice.svg

+6
Loading

0 commit comments

Comments
 (0)