Skip to content

Commit

Permalink
release: v2.5.10
Browse files Browse the repository at this point in the history
  • Loading branch information
QC-L authored Sep 20, 2021
2 parents 3279fa7 + 0105efb commit 05dec93
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 12 deletions.
11 changes: 11 additions & 0 deletions .vitepress/theme/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,21 @@
--docsearch-primary-color: var(--c-brand) !important;
}

#play-vite-audio {
padding: 0;
margin-left: 5px;
display: inline-flex;
}

#play-vite-audio img {
opacity: 0.8;
}

/* docs-cn specific */
.cn-footnote {
margin-top: 20px;
}

.cn-footnote .title {
display: block;
margin-bottom: 10px;
Expand Down
18 changes: 17 additions & 1 deletion config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,22 @@ export default defineConfig(async ({ command, mode }) => {
- **类型:** `string | RegExp | (string | RegExp)[]`
- **相关内容:** [静态资源处理](/guide/assets)

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

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

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

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

**示例:**

```js
export default defineConfig({
assetsInclude: ['**/*.gltf']
})
```

### logLevel {#loglevel}

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

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

### build.ssrManifest {#build-ssrmanifest}

- **类型:** `boolean`
- **默认值:** `false`
- **相关链接:** [Server-Side Rendering](/guide/ssr)

当设置为 `true` 时,构建也将生成 SSR 的 manifest 文件,以确定生产中的样式链接与资产预加载指令。

### build.minify {#build-minify}

- **类型:** `boolean | 'terser' | 'esbuild'`
Expand Down
23 changes: 13 additions & 10 deletions guide/api-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ interface ViteDevServer {
* 应用 Vite 内建 HTML 转换和任意插件 HTML 转换
*/
transformIndexHtml(url: string, html: string): Promise<string>
/**
* 使用 esbuild 转换一个文件的工具函数
* 对某些特定插件十分有用
*/
transformWithEsbuild(
code: string,
filename: string,
options?: EsbuildTransformOptions,
inMap?: object
): Promise<ESBuildTransformResult>
/**
* 加载一个给定的 URL 作为 SSR 的实例化模块
*/
Expand Down Expand Up @@ -157,3 +147,16 @@ async function resolveConfig(
defaultMode?: string
): Promise<ResolvedConfig>
```

## `transformWithEsbuild`

**类型签名:**

```ts
async function transformWithEsbuild(
code: string,
filename: string,
options?: EsbuildTransformOptions,
inMap?: object
): Promise<ESBuildTransformResult>
```
11 changes: 11 additions & 0 deletions guide/api-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ Vite 插件扩展了设计出色的 Rollup 接口,带有一些 Vite 独有的

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

## 致插件创作者 {#authoring-a-plugin}

Vite 努力秉承开箱即用的原则,因此在创作一款新插件前,请确保已经阅读过 [Vite 的功能指南](/guide/features),避免重复劳作。同时还应查看社区是否存在可用插件,包括 [兼容 Rollup 的插件](https://github.com/rollup/awesome) 以及 [Vite 的专属插件](https://github.com/vitejs/awesome-vite#plugins)

当创作插件时,你可以在 `vite.config.js` 中直接使用它。没必要直接为它创建一个新的 package。当你发现某个插件在你项目中很有用时,可以考虑,可以考虑 [在社区中](https://chat.vitejs.dev) 将其与他人分享。

::: tip
在学习、调试或创作插件时,我们建议在你的项目中引入 [vite-plugin-inspect](https://github.com/antfu/vite-plugin-inspect)。 它可以帮助你检查 Vite 插件的中间状态。安装后,你可以访问 `localhost:3000/__inspect/` 来检查你项目的模块和栈信息。请查阅 [vite-plugin-inspect 文档](https://github.com/antfu/vite-plugin-inspect) 中的安装说明。
![vite-plugin-inspect](/images/vite-plugin-inspect.png)
:::

## 约定 {#conventions}

如果插件不使用 Vite 特有的钩子,可以实现为 [兼容的 Rollup 插件](#rollup-plugin-compatibility),推荐使用 [Rollup 插件名称约定](https://rollupjs.org/guide/en/#conventions)
Expand Down
6 changes: 5 additions & 1 deletion guide/index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# 开始 {#getting-started}

<audio id="vite-audio">
<source src="/vite.mp3" type="audio/mpeg">
</audio>

## 总览 {#overview}

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

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

Expand Down
Binary file added images/vite-plugin-inspect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/vite.mp3
Binary file not shown.
6 changes: 6 additions & 0 deletions public/voice.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 05dec93

Please sign in to comment.