Skip to content

Commit 28eb01c

Browse files
authored
release: v2.7.0
2 parents d0d0c8c + 795c70b commit 28eb01c

File tree

7 files changed

+35
-21
lines changed

7 files changed

+35
-21
lines changed

config/index.md

+18-10
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,14 @@ export default defineConfig(async ({ command, mode }) => {
235235
| ((name: string, filename: string, css: string) => string)
236236
hashPrefix?: string
237237
/**
238-
* 默认:'camelCaseOnly'
238+
* default: null
239239
*/
240-
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly'
240+
localsConvention?:
241+
| 'camelCase'
242+
| 'camelCaseOnly'
243+
| 'dashes'
244+
| 'dashesOnly'
245+
| null
241246
}
242247
```
243248

@@ -785,12 +790,12 @@ export default defineConfig({
785790

786791
默认情况下,若 `outDir``root` 目录下,则 Vite 会在构建时清空该目录。若 `outDir` 在根目录之外则会抛出一个警告避免意外删除掉重要的文件。可以设置该选项来关闭这个警告。该功能也可以通过命令行参数 `--emptyOutDir` 来使用。
787792

788-
### build.brotliSize {#build-brotlisize}
793+
### build.reportCompressedSize {#build-reportcompressedsize}
789794

790795
- **类型:** `boolean`
791796
- **默认:** `true`
792797

793-
启用/禁用 brotli 压缩大小报告。压缩大型输出文件可能会很慢,因此禁用该功能可能会提高大型项目的构建性能。
798+
启用/禁用 gzip 压缩大小报告。压缩大型输出文件可能会很慢,因此禁用该功能可能会提高大型项目的构建性能。
794799

795800
### build.chunkSizeWarningLimit {#build-chunksizewarninglimit}
796801

@@ -914,14 +919,17 @@ export default defineConfig({
914919

915920
默认情况下,不在 `node_modules` 中的,链接的包不会被预构建。使用此选项可强制预构建链接的包。
916921

917-
### optimizeDeps.keepNames {#optimizedeps-keepnames}
922+
### optimizeDeps.esbuildOptions {#optimizedeps-esbuildoptions}
918923

919-
- **类型:** `boolean`
920-
- **默认:** `false`
924+
- **类型:** [`EsbuildBuildOptions`](https://esbuild.github.io/api/#simple-options)
925+
926+
在部署扫描和优化过程中传递给 esbuild 的选项。
927+
928+
某些选项进行了省略,因为修改它们与 Vite 的优化方案并不兼容。
921929

922-
打包器有时需要重命名符号以避免冲突。
923-
设置此项为 `true` 可以在函数和类上保留 `name` 属性。
924-
若想获取更多详情,请参阅 [`keepNames`](https://esbuild.github.io/api/#keep-names)
930+
- 忽略了 `external` 选项,请使用 Vite 的 `optimizeDeps.exclude` 选项
931+
- `plugins` 与 Vite 的 dep 插件合并
932+
- `keepNames` 优级高于被废弃的 `optimizeDeps.keepNames`
925933

926934
## SSR 选项 {#ssr-options}
927935

guide/api-plugin.md

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Vite 努力秉承开箱即用的原则,因此在创作一款新插件前,请
3636
- `vite-plugin-react-` 前缀作为 React 插件
3737
- `vite-plugin-svelte-` 前缀作为 Svelte 插件
3838

39-
4039
Vite 对虚拟模块的规范是在路径前加上 `virtual:`。如果可能的话,插件名应该作为命名空间使用,以避免与生态系统中的其他插件发生冲突。例如,`vite-plugin-posts` 可以让用户引入 `virtual:posts``virtual:posts/helpers` 虚拟模块,以获得构建时信息。在内部,使用虚拟模块的插件在解析模块 ID 时应以 `\0` 为前缀,这是一个来自 Rollup 生态系统的惯例。这可以防止其他插件试图处理这个 ID(如节点解析),而像 sourcemap 这样的核心功能可以使用这些信息来区分虚拟模块和普通文件。`\0` 在导入的 URL 中不是一个允许的字符,所以我们必须在导入分析中替换它们。在浏览器中,一个 `0{id}` 的虚拟 ID 最终被编码为 `/@id/__x00__{id}`。在进入插件处理管道之前,这个 ID 会被解码回来。所以这个过程在插件钩子代码中将是不可见的。
4140

4241
请注意,模块都直接来源于真实的文件,而单文件组件(比如 .vue 或 .svelte 文件)中的 script 模块将不需要这样的转换。单文件组件被处理时一般会生成一系列子模块但其代码都可以被映射回文件系统。对这些子模块使用 `\0` 会使得 sourcemap 工作异常。

guide/backend-integration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
还要确保服务器配置为提供 Vite 工作目录中的静态资源,否则图片等资源将无法正确加载。
4141

42-
如果你正使用 `@vitejs/plugin-react-refresh` 配合 React,你还需要在上述脚本前添加下面这个,因为插件不能修改你正在服务的 HTML:
42+
如果你正使用 `@vitejs/plugin-react` 配合 React,你还需要在上述脚本前添加下面这个,因为插件不能修改你正在服务的 HTML:
4343

4444
```html
4545
<script type="module">

guide/index.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ Vite 也支持多个 `.html` 作入口点的 [多页面应用模式](./build#mul
115115

116116
在安装了 Vite 的项目中,可以在 npm scripts 中使用 `vite` 可执行文件,或者直接使用 `npx vite` 运行它。下面是通过脚手架创建的 Vite 项目中默认的 npm scripts:
117117

118-
```jsonc
118+
<!-- prettier-ignore -->
119+
```json5
119120
{
120121
"scripts": {
121122
"dev": "vite", // 启动开发服务器,别名:`vite dev`,`vite serve`

guide/migration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default defineConfig({
9090

9191
## React 支持 {#react-support}
9292

93-
现已支持 React Fast Refresh,详见 [`@vitejs/plugin-react-refresh`](https://github.com/vitejs/vite/tree/main/packages/plugin-react-refresh)
93+
现已支持 React Fast Refresh,详见 [`@vitejs/plugin-react`](https://github.com/vitejs/vite/tree/main/packages/plugin-react)
9494

9595
## HMR API 变化 {#hmr-api-change}
9696

guide/ssr.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Vite 为服务端渲染(SSR)提供了内建支持。这里的 Vite 范例包
3131

3232
```
3333
- index.html
34+
- server.js # main application server
3435
- src/
3536
- main.js # 导出环境无关的(通用的)应用代码
3637
- entry-client.js # 将应用挂载到一个 DOM 元素上
@@ -76,8 +77,13 @@ async function createServer() {
7677
// 以中间件模式创建 Vite 应用,这将禁用 Vite 自身的 HTML 服务逻辑
7778
// 并让上级服务器接管控制
7879
//
80+
<<<<<<< HEAD
7981
// 如果你想使用 Vite 自己的 HTML 服务逻辑(将 Vite 作为
8082
// 一个开发中间件来使用),那么这里请用 'html'
83+
=======
84+
// In middleware mode, if you want to use Vite's own HTML serving logic
85+
// use `'html'` as the `middlewareMode` (ref https://vitejs.dev/config/#server-middlewaremode)
86+
>>>>>>> 7ee013df1d23732b3f0f880c414c161ad21657f5
8187
const vite = await createViteServer({
8288
server: { middlewareMode: 'ssr' }
8389
})
@@ -111,7 +117,7 @@ app.use('*', async (req, res) => {
111117

112118
// 2. 应用 Vite HTML 转换。这将会注入 Vite HMR 客户端,
113119
// 同时也会从 Vite 插件应用 HTML 转换。
114-
// 例如:@vitejs/plugin-react-refresh 中的 global preambles
120+
// 例如:@vitejs/plugin-react 中的 global preambles
115121
template = await vite.transformIndexHtml(url, template)
116122

117123
// 3. 加载服务器入口。vite.ssrLoadModule 将自动转换
@@ -250,8 +256,8 @@ export function mySSRPlugin() {
250256
251257
`options` 中的 `load``transform` 为可选项,rollup 目前并未使用该对象,但将来可能会用额外的元数据来扩展这些钩子函数。
252258
253-
::: 注意
254-
Vite 2.7 之前的版本,会提示你 `ssr` 参数的位置不应该是 `options` 对象。目前所有主框架和插件都已对应更新,但你可能还会发现使用过时 API 的旧文章。
259+
:::tip Note
260+
Vite 2.7 之前的版本,会提示你 `ssr` 参数的位置不应该是 `options` 对象。目前所有主要框架和插件都已对应更新,但你可能还是会发现使用过时 API 的旧文章。
255261
:::
256262
257263
## SSR Target {#ssr-target}

guide/static-deploy.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ $ npm run preview
8787
# git push -f [email protected]:<USERNAME>/<USERNAME>.github.io.git main
8888
8989
# 如果你要部署在 https://<USERNAME>.github.io/<REPO>
90-
# git push -f [email protected]:<USERNAME>/<REPO>.git master:gh-pages
90+
# git push -f [email protected]:<USERNAME>/<REPO>.git main:gh-pages
9191
9292
cd -
9393
```
@@ -127,7 +127,7 @@ $ npm run preview
127127
github_token: $GITHUB_TOKEN
128128
keep_history: true
129129
on:
130-
branch: master
130+
branch: main
131131
```
132132
133133
## GitLab Pages 配合 GitLab CI {#gitlab-pages-and-gitlab-ci}
@@ -159,7 +159,7 @@ $ npm run preview
159159
paths:
160160
- public
161161
rules:
162-
- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
162+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
163163
```
164164

165165
## Netlify {#netlify}
@@ -259,7 +259,7 @@ $ npm run preview
259259

260260
```bash
261261
# 发布站点
262-
$ git push heroku master
262+
$ git push heroku main
263263
264264
# 在浏览器中打开 Heroku 的面板
265265
$ heroku open

0 commit comments

Comments
 (0)