From f4460bcdf637f80a3995f4bb16c36c7316da5e1b Mon Sep 17 00:00:00 2001 From: Konv Suu <2583695112@qq.com> Date: Tue, 6 May 2025 17:55:30 +0800 Subject: [PATCH] fix: update rollup links to cn documentation --- .vitepress/config.ts | 2 +- blog/announcing-vite4.md | 2 +- blog/announcing-vite5.md | 2 +- config/build-options.md | 6 +++--- config/server-options.md | 4 ++-- config/worker-options.md | 2 +- guide/api-plugin.md | 28 ++++++++++++++-------------- guide/build.md | 10 +++++----- guide/index.md | 2 +- guide/migration-from-v1.md | 6 +++--- guide/migration-from-v2.md | 2 +- guide/migration-from-v3.md | 2 +- guide/performance.md | 2 +- guide/philosophy.md | 2 +- guide/troubleshooting.md | 2 +- guide/why.md | 2 +- 16 files changed, 38 insertions(+), 38 deletions(-) diff --git a/.vitepress/config.ts b/.vitepress/config.ts index 1c9e1133..4735b086 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -528,7 +528,7 @@ Vite is a new breed of frontend build tooling that significantly improves the fr - A dev server that serves your source files over [native ES modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), with [rich built-in features](https://vite.dev/guide/features.md) and astonishingly fast [Hot Module Replacement (HMR)](https://vite.dev/guide/features.md#hot-module-replacement). -- A [build command](https://vite.dev/guide/build.md) that bundles your code with [Rollup](https://rollupjs.org), pre-configured to output highly optimized static assets for production. +- A [build command](https://vite.dev/guide/build.md) that bundles your code with [Rollup](https://cn.rollupjs.org), pre-configured to output highly optimized static assets for production. In addition, Vite is highly extensible via its [Plugin API](https://vite.dev/guide/api-plugin.md) and [JavaScript API](https://vite.dev/guide/api-javascript.md) with full typing support.`, }) as PluginOption, diff --git a/blog/announcing-vite4.md b/blog/announcing-vite4.md index f17bca9c..9f574f54 100644 --- a/blog/announcing-vite4.md +++ b/blog/announcing-vite4.md @@ -33,7 +33,7 @@ Vite 3 [was released](./announcing-vite3.md) five months ago. npm downloads per [![Vite 4 Ecosystem](/ecosystem-vite4.png)](https://viteconf.org/2022/replay) -As a showcase of the growth Vite and related projects have experienced, the Vite ecosystem gathered on October 11th at [ViteConf 2022](https://viteconf.org/2022/replay). We saw representatives from the main web framework and tools tell stories of innovation and collaboration. And in a symbolic move, the Rollup team choose that exact day to release [Rollup 3](https://rollupjs.org). +As a showcase of the growth Vite and related projects have experienced, the Vite ecosystem gathered on October 11th at [ViteConf 2022](https://viteconf.org/2022/replay). We saw representatives from the main web framework and tools tell stories of innovation and collaboration. And in a symbolic move, the Rollup team choose that exact day to release [Rollup 3](https://cn.rollupjs.org). Today, the Vite [team](https://vite.dev/team) with the help of our ecosystem partners, is happy to announce the release of Vite 4, powered during build time by Rollup 3. We've worked with the ecosystem to ensure a smooth upgrade path for this new major. Vite is now using [Rollup 3](https://github.com/vitejs/vite/issues/9870), which allowed us to simplify Vite's internal asset handling and has many improvements. See the [Rollup 3 release notes here](https://github.com/rollup/rollup/releases/tag/v3.0.0). diff --git a/blog/announcing-vite5.md b/blog/announcing-vite5.md index a5a6c284..e490d4d3 100644 --- a/blog/announcing-vite5.md +++ b/blog/announcing-vite5.md @@ -33,7 +33,7 @@ _2023年11月16日_ Vite 4 发布了将近一年,它为生态系统奠定了坚实的基础。每周的 npm 下载量从250万增加到了750万,因为项目不断在共享基础设施上构建。各种框架不断创新,除了 [Astro](https://astro.build/)、[Nuxt](https://nuxt.com/)、[SvelteKit](https://kit.svelte.dev/)、[Solid Start](https://www.solidjs.com/blog/introducing-solidstart)、[Qwik City](https://qwik.builder.io/qwikcity/overview/) 等等之外,我们看到新的框架加入并使生态系统变得更加强大。[RedwoodJS](https://redwoodjs.com/) 和 [Remix](https://remix.run/) 转向 Vite 为 React 生态系统的进一步采用铺平了道路。[Vitest](https://vitest.dev) 的增长速度甚至比 Vite 还要快。其团队一直在努力工作,并将很快 [发布 Vitest 1.0](https://github.com/vitest-dev/vitest/issues/3596)。当与其他工具一起使用时,如 [Storybook](https://storybook.js.org)、[Nx](https://nx.dev) 和 [Playwright](https://playwright.dev),Vite 的故事不断改善,环境也是如此,Vite 的开发在 [Deno](https://deno.com) 和 [Bun](https://bun.sh) 中都可以工作。 -一个月前,我们举办了第二届 [ViteConf](https://viteconf.org/23/replay),由 [StackBlitz](https://stackblitz.com) 主办。像去年一样,生态系统中的大多数项目聚在一起分享想法,并保持连接以持续扩展共同体。我们也看到新的组件补充了元框架工具包,比如 [Volar](https://volarjs.dev/) 和 [Nitro](https://nitro.unjs.io/)。Rollup 团队在同一天发布了 [Rollup 4](https://rollupjs.org),这是去年 Lukas 开创的传统。 +一个月前,我们举办了第二届 [ViteConf](https://viteconf.org/23/replay),由 [StackBlitz](https://stackblitz.com) 主办。像去年一样,生态系统中的大多数项目聚在一起分享想法,并保持连接以持续扩展共同体。我们也看到新的组件补充了元框架工具包,比如 [Volar](https://volarjs.dev/) 和 [Nitro](https://nitro.unjs.io/)。Rollup 团队在同一天发布了 [Rollup 4](https://cn.rollupjs.org),这是去年 Lukas 开创的传统。 六个月前,Vite 4.3 [发布了](./announcing-vite4.md)。这个版本显著改善了开发服务器的性能。但是,还有很大的改进空间。在 ViteConf 上,[Evan You 揭示了 Vite 的长期计划,即着手开发 Rolldown](https://www.youtube.com/watch?v=hrdwQHoAp0M),这是 Rollup 的 Rust 版本,具有兼容的 API。一旦准备就绪,我们打算在 Vite Core 中使用它,以执行 Rollup 和 esbuild 的任务。这将意味着构建性能的提升(随着我们将 Vite 本身的性能敏感部分转移到 Rust,开发性能也将在以后提升),以及减少开发和构建之间的不一致性。Rolldown 目前处于早期阶段,团队正准备在年底之前开源代码库。敬请期待! diff --git a/config/build-options.md b/config/build-options.md index 0267629a..85da3637 100644 --- a/config/build-options.md +++ b/config/build-options.md @@ -143,9 +143,9 @@ Git LFS 占位符会自动排除在内联之外,因为它们不包含其所表 ## build.rollupOptions {#build-rollupoptions} -- **类型:** [`RollupOptions`](https://rollupjs.org/configuration-options/) +- **类型:** [`RollupOptions`](https://cn.rollupjs.org/configuration-options/) -自定义底层的 Rollup 打包配置。这与从 Rollup 配置文件导出的选项相同,并将与 Vite 的内部 Rollup 选项合并。查看 [Rollup 选项文档](https://rollupjs.org/configuration-options/) 获取更多细节。 +自定义底层的 Rollup 打包配置。这与从 Rollup 配置文件导出的选项相同,并将与 Vite 的内部 Rollup 选项合并。查看 [Rollup 选项文档](https://cn.rollupjs.org/configuration-options/) 获取更多细节。 ## build.commonjsOptions {#build-commonjsoptions} @@ -287,7 +287,7 @@ npm add -D terser ## build.watch {#build-watch} -- **类型:** [`WatcherOptions`](https://rollupjs.org/configuration-options/#watch)`| null` +- **类型:** [`WatcherOptions`](https://cn.rollupjs.org/configuration-options/#watch)`| null` - **默认:** `null` 设置为 `{}` 则会启用 rollup 的监听器。对于只在构建阶段或者集成流程使用的插件很常用。 diff --git a/config/server-options.md b/config/server-options.md index b1104110..fffbe2ea 100644 --- a/config/server-options.md +++ b/config/server-options.md @@ -398,7 +398,7 @@ export default defineConfig({ 是否忽略服务器 sourcemap 中的源文件,用于填充 [`x_google_ignoreList` source map 扩展](https://developer.chrome.com/articles/x-google-ignore-list/)。 -对开发服务器来说 `server.sourcemapIgnoreList` 等价于 [`build.rollupOptions.output.sourcemapIgnoreList`](https://rollupjs.org/configuration-options/#output-sourcemapignorelist)。两个配置选项之间的区别在于,rollup 函数使用相对路径调用 `sourcePath`,而 `server.sourcemapIgnoreList` 使用绝对路径调用。在开发过程中,大多数模块的映射和源文件位于同一个文件夹中,因此 `sourcePath` 的相对路径就是文件名本身。在这些情况下,使用绝对路径更加方便。 +对开发服务器来说 `server.sourcemapIgnoreList` 等价于 [`build.rollupOptions.output.sourcemapIgnoreList`](https://cn.rollupjs.org/configuration-options/#output-sourcemapignorelist)。两个配置选项之间的区别在于,rollup 函数使用相对路径调用 `sourcePath`,而 `server.sourcemapIgnoreList` 使用绝对路径调用。在开发过程中,大多数模块的映射和源文件位于同一个文件夹中,因此 `sourcePath` 的相对路径就是文件名本身。在这些情况下,使用绝对路径更加方便。 默认情况下,它会排除所有包含 `node_modules` 的路径。你可以传递 `false` 来禁用此行为,或者为了获得完全的控制,可以传递一个函数,该函数接受源路径和 sourcemap 的路径,并返回是否忽略源路径。 @@ -415,5 +415,5 @@ export default defineConfig({ ``` ::: tip 注意 -需要单独设置 [`server.sourcemapIgnoreList`](#server-sourcemapignorelist) 和 [`build.rollupOptions.output.sourcemapIgnoreList`](https://rollupjs.org/configuration-options/#output-sourcemapignorelist)。`server.sourcemapIgnoreList` 是一个仅适用于服务端的配置,并不从定义好的 rollup 选项中获得其默认值。 +需要单独设置 [`server.sourcemapIgnoreList`](#server-sourcemapignorelist) 和 [`build.rollupOptions.output.sourcemapIgnoreList`](https://cn.rollupjs.org/configuration-options/#output-sourcemapignorelist)。`server.sourcemapIgnoreList` 是一个仅适用于服务端的配置,并不从定义好的 rollup 选项中获得其默认值。 ::: diff --git a/config/worker-options.md b/config/worker-options.md index 00009c0b..fe954b59 100644 --- a/config/worker-options.md +++ b/config/worker-options.md @@ -18,6 +18,6 @@ worker 打包时的输出类型。 ## worker.rollupOptions -- **类型:** [`RollupOptions`](https://rollupjs.org/configuration-options/) +- **类型:** [`RollupOptions`](https://cn.rollupjs.org/configuration-options/) 用于打包 worker 的 Rollup 配置项。 diff --git a/guide/api-plugin.md b/guide/api-plugin.md index 943b242f..305d09da 100644 --- a/guide/api-plugin.md +++ b/guide/api-plugin.md @@ -2,7 +2,7 @@ Vite 插件扩展了设计出色的 Rollup 接口,带有一些 Vite 独有的配置项。因此,你只需要编写一个 Vite 插件,就可以同时为开发环境和生产环境工作。 -**推荐在阅读下面的章节之前,首先阅读下 [Rollup 插件文档](https://rollupjs.org/plugin-development/)** +**推荐在阅读下面的章节之前,首先阅读下 [Rollup 插件文档](https://cn.rollupjs.org/plugin-development/)** ## 致插件创作者 {#authoring-a-plugin} @@ -17,7 +17,7 @@ Vite 努力秉承开箱即用的原则,因此在创作一款新插件前,请 ## 约定 {#conventions} -如果插件不使用 Vite 特有的钩子,可以作为 [兼容 Rollup 的插件](#rollup-plugin-compatibility) 来实现,推荐使用 [Rollup 插件名称约定](https://rollupjs.org/plugin-development/#conventions)。 +如果插件不使用 Vite 特有的钩子,可以作为 [兼容 Rollup 的插件](#rollup-plugin-compatibility) 来实现,推荐使用 [Rollup 插件名称约定](https://cn.rollupjs.org/plugin-development/#conventions)。 - Rollup 插件应该有一个带 `rollup-plugin-` 前缀、语义清晰的名称。 - 在 package.json 中包含 `rollup-plugin` 和 `vite-plugin` 关键字。 @@ -144,18 +144,18 @@ console.log(msg) ## 通用钩子 {#universal-hooks} -在开发中,Vite 开发服务器会创建一个插件容器来调用 [Rollup 构建钩子](https://rollupjs.org/plugin-development/#build-hooks),与 Rollup 如出一辙。 +在开发中,Vite 开发服务器会创建一个插件容器来调用 [Rollup 构建钩子](https://cn.rollupjs.org/plugin-development/#build-hooks),与 Rollup 如出一辙。 以下钩子在服务器启动时被调用: -- [`options`](https://rollupjs.org/plugin-development/#options) -- [`buildStart`](https://rollupjs.org/plugin-development/#buildstart) +- [`options`](https://cn.rollupjs.org/plugin-development/#options) +- [`buildStart`](https://cn.rollupjs.org/plugin-development/#buildstart) 以下钩子会在每个传入模块请求时被调用: -- [`resolveId`](https://rollupjs.org/plugin-development/#resolveid) -- [`load`](https://rollupjs.org/plugin-development/#load) -- [`transform`](https://rollupjs.org/plugin-development/#transform) +- [`resolveId`](https://cn.rollupjs.org/plugin-development/#resolveid) +- [`load`](https://cn.rollupjs.org/plugin-development/#load) +- [`transform`](https://cn.rollupjs.org/plugin-development/#transform) 它们还有一个扩展的 `options` 参数,包含其他特定于 Vite 的属性。你可以在 [SSR 文档](/guide/ssr#ssr-specific-plugin-logic) 中查阅更多内容。 @@ -163,12 +163,12 @@ console.log(msg) 以下钩子在服务器关闭时被调用: -- [`buildEnd`](https://rollupjs.org/plugin-development/#buildend) -- [`closeBundle`](https://rollupjs.org/plugin-development/#closebundle) +- [`buildEnd`](https://cn.rollupjs.org/plugin-development/#buildend) +- [`closeBundle`](https://cn.rollupjs.org/plugin-development/#closebundle) -请注意 [`moduleParsed`](https://rollupjs.org/plugin-development/#moduleparsed) 钩子在开发中是 **不会** 被调用的,因为 Vite 为了性能会避免完整的 AST 解析。 +请注意 [`moduleParsed`](https://cn.rollupjs.org/plugin-development/#moduleparsed) 钩子在开发中是 **不会** 被调用的,因为 Vite 为了性能会避免完整的 AST 解析。 -[Output Generation Hooks](https://rollupjs.org/plugin-development/#output-generation-hooks)(除了 `closeBundle`) 在开发中是 **不会** 被调用的。你可以认为 Vite 的开发服务器只调用了 `rollup.rollup()` 而没有调用 `bundle.generate()`。 +[Output Generation Hooks](https://cn.rollupjs.org/plugin-development/#output-generation-hooks)(除了 `closeBundle`) 在开发中是 **不会** 被调用的。你可以认为 Vite 的开发服务器只调用了 `rollup.rollup()` 而没有调用 `bundle.generate()`。 ## Vite 独有钩子 {#vite-specific-hooks} @@ -479,7 +479,7 @@ Vite 插件也可以提供钩子来服务于特定的 Vite 目标。这些钩子 - 带有 `enforce: 'post'` 的用户插件 - Vite 后置构建插件(最小化,manifest,报告) -请注意,这与钩子的排序是分开的,钩子的顺序仍然会受到它们的 `order` 属性的影响,这一点 [和 Rollup 钩子的表现一样](https://rollupjs.org/plugin-development/#build-hooks)。 +请注意,这与钩子的排序是分开的,钩子的顺序仍然会受到它们的 `order` 属性的影响,这一点 [和 Rollup 钩子的表现一样](https://cn.rollupjs.org/plugin-development/#build-hooks)。 ## 情景应用 {#conditional-application} @@ -509,7 +509,7 @@ apply(config, { command }) { 一般来说,只要 Rollup 插件符合以下标准,它就应该像 Vite 插件一样工作: -- 没有使用 [`moduleParsed`](https://rollupjs.org/plugin-development/#moduleparsed) 钩子。 +- 没有使用 [`moduleParsed`](https://cn.rollupjs.org/plugin-development/#moduleparsed) 钩子。 - 它在打包钩子和输出钩子之间没有很强的耦合。 如果一个 Rollup 插件只在构建阶段有意义,则在 `build.rollupOptions.plugins` 下指定即可。它的工作原理与 Vite 插件的 `enforce: 'post'` 和 `apply: 'build'` 相同。 diff --git a/guide/build.md b/guide/build.md index 468f6fff..e5662d49 100644 --- a/guide/build.md +++ b/guide/build.md @@ -50,13 +50,13 @@ ## 自定义构建 {#customizing-the-build} -构建过程可以通过多种 [构建配置选项](/config/#build-options) 来自定义构建。具体来说,你可以通过 `build.rollupOptions` 直接调整底层的 [Rollup 选项](https://rollupjs.org/configuration-options/): +构建过程可以通过多种 [构建配置选项](/config/#build-options) 来自定义构建。具体来说,你可以通过 `build.rollupOptions` 直接调整底层的 [Rollup 选项](https://cn.rollupjs.org/configuration-options/): ```js [vite.config.js] export default defineConfig({ build: { rollupOptions: { - // https://rollupjs.org/configuration-options/ + // https://cn.rollupjs.org/configuration-options/ }, }, }) @@ -82,13 +82,13 @@ window.addEventListener('vite:preloadError', (event) => { ## 文件变化时重新构建 {#rebuild-on-files-changes} -你可以使用 `vite build --watch` 来启用 rollup 的监听器。或者,你可以直接通过 `build.watch` 调整底层的 [`WatcherOptions`](https://rollupjs.org/configuration-options/#watch) 选项: +你可以使用 `vite build --watch` 来启用 rollup 的监听器。或者,你可以直接通过 `build.watch` 调整底层的 [`WatcherOptions`](https://cn.rollupjs.org/configuration-options/#watch) 选项: ```js [vite.config.js] export default defineConfig({ build: { watch: { - // https://rollupjs.org/configuration-options/#watch + // https://cn.rollupjs.org/configuration-options/#watch }, }, }) @@ -306,7 +306,7 @@ dist/my-lib.umd.cjs 0.30 kB / gzip: 0.16 kB ::: ::: warning 进阶用法 -库模式包括了一种简单而又有见地的配置,适用于面向浏览器和 JS 框架的库。如果你正在构建非面向浏览器的库,或需要高级构建流程,可以直接使用 [Rollup](https://rollupjs.org) 或 [esbuild](https://esbuild.github.io)。 +库模式包括了一种简单而又有见地的配置,适用于面向浏览器和 JS 框架的库。如果你正在构建非面向浏览器的库,或需要高级构建流程,可以直接使用 [Rollup](https://cn.rollupjs.org) 或 [esbuild](https://esbuild.github.io)。 ::: ## 进阶基础路径选项 {#advanced-base-options} diff --git a/guide/index.md b/guide/index.md index 9e4b8768..3ec27c36 100644 --- a/guide/index.md +++ b/guide/index.md @@ -10,7 +10,7 @@ Vite(法语意为 "快速的",发音 `/vit/`