From 59763a224a2078dfc7a40b722d47503544b61b13 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 6 Nov 2025 10:47:19 +0800 Subject: [PATCH 1/8] docs: enable cleanUrls (#21072) --- .vitepress/config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/.vitepress/config.ts b/.vitepress/config.ts index 08f585c3..f7ecb8e6 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -87,6 +87,7 @@ function inlineScript(file: string): HeadConfig { export default defineConfig({ title: `Vite${additionalTitle}`, description: 'Next Generation Frontend Tooling', + cleanUrls: true, head: [ ['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }], From 42829286b1afc421c4fb7284cd14eef6ad7f72bd Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 6 Nov 2025 10:53:32 +0800 Subject: [PATCH 2/8] docs(features): add license section (#21071) Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> --- config/build-options.md | 23 +++-------------------- guide/features.md | 36 ++++++++++++++++++++++++++++++++++++ releases.md | 2 +- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/config/build-options.md b/config/build-options.md index e2366036..59282616 100644 --- a/config/build-options.md +++ b/config/build-options.md @@ -189,28 +189,11 @@ export default defineConfig({ - **Type:** `boolean | { fileName?: string }` - **Default:** `false` +- **Related:** [License](/guide/features#license) -When set to `true`, the build will generate a `.vite/license.md` file that includes all bundled dependencies' licenses. It can be hosted to display and acknowledge the dependencies used by the app. When `fileName` is passed, it will be used as the license file name relative to the `outDir`. An example output may look like this: +When set to `true`, the build will generate a `.vite/license.md` file that includes all bundled dependencies' licenses. -```md -# Licenses - -The app bundles dependencies which contain the following licenses: - -## dep-1 - 1.2.3 (CC0-1.0) - -CC0 1.0 Universal - -... - -## dep-2 - 4.5.6 (MIT) - -MIT License - -... -``` - -If the `fileName` ends with `.json`, the raw JSON metadata will be generated instead and can be used for further processing. For example: +If `fileName` is passed, it will be used as the license file name relative to the `outDir`. If it ends with `.json`, the raw JSON metadata will be generated instead and can be used for further processing. For example: ```json [ diff --git a/guide/features.md b/guide/features.md index a879be14..c7caead3 100644 --- a/guide/features.md +++ b/guide/features.md @@ -789,6 +789,42 @@ By default, during build, Vite inlines small assets as data URIs. Allowing `data Do not allow `data:` for [`script-src`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src). It will allow injection of arbitrary scripts. ::: +## License + +Vite can generate a file of all the dependencies' licenses used in the build with the [`build.license`](/config/build-options.md#build-license) option. It can be hosted to display and acknowledge the dependencies used by the app. + +```js twoslash [vite.config.js] +import { defineConfig } from 'vite' + +export default defineConfig({ + build: { + license: true, + }, +}) +``` + +This will generate a `.vite/license.md` file with an output that may look like this: + +```md +# Licenses + +The app bundles dependencies which contain the following licenses: + +## dep-1 - 1.2.3 (CC0-1.0) + +CC0 1.0 Universal + +... + +## dep-2 - 4.5.6 (MIT) + +MIT License + +... +``` + +To serve the file at a different path, you can pass `{ fileName: 'license.md' }` for example, so that it's served at `https://example.com/license.md`. See the [`build.license`](/config/build-options.md#build-license) docs for more information. + ## Build Optimizations > Features listed below are automatically applied as part of the build process and there is no need for explicit configuration unless you want to disable them. diff --git a/releases.md b/releases.md index 14e81380..83271f97 100644 --- a/releases.md +++ b/releases.md @@ -24,7 +24,7 @@ In summary, the current supported Vite versions are:
-The supported version ranges are are automatically determined by: +The supported version ranges are automatically determined by: - **Current Minor** gets regular fixes. - **Previous Major** (only for its latest minor) and **Previous Minor** receives important fixes and security patches. From d57f75d7b4fb78922453020d2d51c9b1343ebad1 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Thu, 6 Nov 2025 12:08:32 +0900 Subject: [PATCH 3/8] docs(static-deploy): clarify GitHub Pages instructions (enable + workflow) (#21020) Co-authored-by: Bjorn Lu --- guide/static-deploy.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/guide/static-deploy.md b/guide/static-deploy.md index 64078a3a..eec2c8fa 100644 --- a/guide/static-deploy.md +++ b/guide/static-deploy.md @@ -55,13 +55,25 @@ Now the `preview` command will launch the server at `http://localhost:8080`. ## GitHub Pages -1. Set the correct `base` in `vite.config.js`. +1. **Update Vite Config** + + Set the correct `base` in `vite.config.js`. If you are deploying to `https://.github.io/`, or to a custom domain through GitHub Pages (eg. `www.example.com`), set `base` to `'/'`. Alternatively, you can remove `base` from the configuration, as it defaults to `'/'`. If you are deploying to `https://.github.io//` (eg. your repository is at `https://github.com//`), then set `base` to `'//'`. -2. Go to your GitHub Pages configuration in the repository settings page and choose the source of deployment as "GitHub Actions", this will lead you to create a workflow that builds and deploys your project, a sample workflow that installs dependencies and builds using npm is provided: +2. **Enable GitHub Pages** + + In your repository, go to **Settings → Pages**. Under **Build and deployment**, open the **Source** dropdown, and select **GitHub Actions**. + + GitHub will now deploy your site using a GitHub Actions [workflow](https://docs.github.com/en/actions/concepts/workflows-and-actions/workflows), which is necessary since Vite requires a build step for deployment. + +3. **Create a Workflow** + + Create a new file in your repository at `.github/workflows/deploy.yml`. You can also click on **“create your own”** from the previous step, which will generate a starter workflow file for you. + + Here’s a sample workflow that installs dependencies with npm, builds the site, and deploys it whenever you push changes to the `main` branch: <<< ./static-deploy-github-pages.yaml#content [.github/workflows/deploy.yml] From fd30d4eab423b6f35c0036a8f15fd34a787b8e7e Mon Sep 17 00:00:00 2001 From: Kylin <1159469891@qq.com> Date: Fri, 7 Nov 2025 09:55:20 +0800 Subject: [PATCH 4/8] docs: update content --- .vitepress/config.ts | 5 ----- config/build-options.md | 35 ++++------------------------------- guide/features.md | 14 +++++--------- guide/static-deploy.md | 24 ++++++++---------------- releases.md | 4 ---- 5 files changed, 17 insertions(+), 65 deletions(-) diff --git a/.vitepress/config.ts b/.vitepress/config.ts index e42cbfad..0dec9ec8 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -48,15 +48,10 @@ function inlineScript(file: string): HeadConfig { } export default defineConfig({ -<<<<<<< HEAD title: 'Vite 官方中文文档', description: '下一代前端工具链', lang: 'zh-CN', -======= - title: `Vite${additionalTitle}`, - description: 'Next Generation Frontend Tooling', cleanUrls: true, ->>>>>>> d57f75d7b4fb78922453020d2d51c9b1343ebad1 head: [ ['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }], diff --git a/config/build-options.md b/config/build-options.md index 2e3a6d52..0e8deed1 100644 --- a/config/build-options.md +++ b/config/build-options.md @@ -187,40 +187,13 @@ export default defineConfig({ ## build.license {#build-license} -<<<<<<< HEAD - **类型:** `boolean | { fileName?: string }` -- **默认:** `false` - -当设置为 `true` 时,构建过程将生成一个 `.vite/license.md` 文件,其中包含所有打包依赖项的许可证信息。该文件可以被托管,用于展示和确认应用程序所使用的依赖项。当传入 `fileName` 参数时,它将被用作相对于 `outDir` 的许可证文件名。示例输出可能如下所示: - -```md -# Licenses - -The app bundles dependencies which contain the following licenses: - -## dep-1 - 1.2.3 (CC0-1.0) - -CC0 1.0 Universal - -... - -## dep-2 - 4.5.6 (MIT) - -MIT License - -... -``` - -如果 `fileName` 以 `.json` 结尾,则会生成原始的 JSON 元数据,可用于进一步处理。例如: -======= -- **Type:** `boolean | { fileName?: string }` -- **Default:** `false` -- **Related:** [License](/guide/features#license) +- **默认:** `false`, +- **相关:** [许可证](/guide/features#license) -When set to `true`, the build will generate a `.vite/license.md` file that includes all bundled dependencies' licenses. +当设置为 `true` 时,构建过程将生成一个 `.vite/license.md` 文件,其中包含所有打包依赖项的许可证信息。 -If `fileName` is passed, it will be used as the license file name relative to the `outDir`. If it ends with `.json`, the raw JSON metadata will be generated instead and can be used for further processing. For example: ->>>>>>> d57f75d7b4fb78922453020d2d51c9b1343ebad1 +如果传入了 `fileName` 参数,它将被用作相对于 `outDir` 的许可证文件名。如果文件名以 `.json` 结尾,则会生成原始的 JSON 元数据,并可以用于进一步处理。例如: ```json [ diff --git a/guide/features.md b/guide/features.md index 7dbd53d7..50861220 100644 --- a/guide/features.md +++ b/guide/features.md @@ -790,12 +790,9 @@ import MyWorker from './worker?worker&url' 不要为 [`script-src`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src) 允许 `data:`。这将会允许注入任何脚本。 ::: -<<<<<<< HEAD -## 构建优化 {#build-optimizations} -======= -## License +## 许可证信息 {#license} -Vite can generate a file of all the dependencies' licenses used in the build with the [`build.license`](/config/build-options.md#build-license) option. It can be hosted to display and acknowledge the dependencies used by the app. +Vite 可以通过 [`build.license`](/config/build-options.md#build-license) 选项生成一个包含构建中使用的所有依赖项许可证的文件。该文件可以被托管,用于显示和确认应用程序所使用的依赖项。 ```js twoslash [vite.config.js] import { defineConfig } from 'vite' @@ -807,7 +804,7 @@ export default defineConfig({ }) ``` -This will generate a `.vite/license.md` file with an output that may look like this: +这将生成一个 `.vite/license.md` 文件,其输出内容可能如下所示: ```md # Licenses @@ -827,10 +824,9 @@ MIT License ... ``` -To serve the file at a different path, you can pass `{ fileName: 'license.md' }` for example, so that it's served at `https://example.com/license.md`. See the [`build.license`](/config/build-options.md#build-license) docs for more information. +要将文件服务于不同的路径,你可以传递 `{ fileName: 'license.md' }` 作为示例,这样它就会在 `https://example.com/license.md` 路径下提供服务。有关更多信息,请参见 [`build.license`](/config/build-options.md#build-license) 文档。 -## Build Optimizations ->>>>>>> d57f75d7b4fb78922453020d2d51c9b1343ebad1 +## 构建优化 {#build-optimizations} > 下面所罗列的功能会自动应用为构建过程的一部分,除非你想禁用它们,否则没有必要显式配置。 diff --git a/guide/static-deploy.md b/guide/static-deploy.md index 1706b05b..42902c16 100644 --- a/guide/static-deploy.md +++ b/guide/static-deploy.md @@ -55,33 +55,25 @@ $ npm run preview ## GitHub Pages {#github-pages} -<<<<<<< HEAD -1. 在 `vite.config.js` 中设置正确的 `base`。 -======= -1. **Update Vite Config** +1. **更新 Vite 配置** - Set the correct `base` in `vite.config.js`. ->>>>>>> d57f75d7b4fb78922453020d2d51c9b1343ebad1 + 在 `vite.config.js` 中设置正确的 `base`。 如果你正要部署到 `https://.github.io/`,或者通过 GitHub Pages 部署到一个自定义域名(例如 `www.example.com`),请将 `base` 设置为 `'/'`。或者,你也可以从配置中移除 `base`,因为它默认为 `'/'`。 如果你正在部署到 `https://.github.io//`(例如你的仓库地址为 `https://github.com//`),那么请将 `base` 设置为 `'//'`。 -<<<<<<< HEAD -2. 进入仓库 settings 页面的 GitHub Pages 配置,选择部署来源为“GitHub Actions”,这将引导你创建一个构建和部署项目的工作流程,我们提供了一个安装依赖项和使用 npm 构建的工作流程样本: -======= -2. **Enable GitHub Pages** +2. **启用 GitHub Pages** - In your repository, go to **Settings → Pages**. Under **Build and deployment**, open the **Source** dropdown, and select **GitHub Actions**. + 在你的仓库中,进入 **Settings → Pages**。在 **Build and deployment** 下,打开 **Source** 下拉菜单,然后选择 **GitHub Actions**。 - GitHub will now deploy your site using a GitHub Actions [workflow](https://docs.github.com/en/actions/concepts/workflows-and-actions/workflows), which is necessary since Vite requires a build step for deployment. + GitHub 现在将使用 GitHub Actions [工作流](https://docs.github.com/en/actions/concepts/workflows-and-actions/workflows)来部署你的网站,这是必要的,因为 Vite 需要构建步骤来进行部署。 -3. **Create a Workflow** +3. **创建工作流** - Create a new file in your repository at `.github/workflows/deploy.yml`. You can also click on **“create your own”** from the previous step, which will generate a starter workflow file for you. + 在你的仓库中创建一个新文件 `.github/workflows/deploy.yml`。你也可以从上一步点击 **"create your own"**,这将为你生成一个起始工作流程文件。 - Here’s a sample workflow that installs dependencies with npm, builds the site, and deploys it whenever you push changes to the `main` branch: ->>>>>>> d57f75d7b4fb78922453020d2d51c9b1343ebad1 + 这里有一个示例工作流程,它使用 npm 安装依赖项,构建网站,并在你向 `main` 分支推送更改时部署它: <<< ./static-deploy-github-pages.yaml#content [.github/workflows/deploy.yml] diff --git a/releases.md b/releases.md index 3b265528..09a86e3d 100644 --- a/releases.md +++ b/releases.md @@ -24,11 +24,7 @@ Vite 没有固定的发布周期。
-<<<<<<< HEAD 支持的版本范围由以下因素确定: -======= -The supported version ranges are automatically determined by: ->>>>>>> d57f75d7b4fb78922453020d2d51c9b1343ebad1 - **当前次要版本** 会定期提供修复。 - **上一个主要版本** (仅限其最新的次要版本)和 **上一个次要版本** 会接收重要修复和安全补丁。 From d3e1a705d05b833f1fc308ae0cecaf4978bfa2d5 Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Fri, 7 Nov 2025 12:29:13 +0800 Subject: [PATCH 5/8] Update guide/features.md --- guide/features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/features.md b/guide/features.md index 50861220..ef912a05 100644 --- a/guide/features.md +++ b/guide/features.md @@ -790,7 +790,7 @@ import MyWorker from './worker?worker&url' 不要为 [`script-src`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src) 允许 `data:`。这将会允许注入任何脚本。 ::: -## 许可证信息 {#license} +## license Vite 可以通过 [`build.license`](/config/build-options.md#build-license) 选项生成一个包含构建中使用的所有依赖项许可证的文件。该文件可以被托管,用于显示和确认应用程序所使用的依赖项。 From 341da82f3f32024576c2bec123e1e9c0c76c9ed2 Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Fri, 7 Nov 2025 12:30:18 +0800 Subject: [PATCH 6/8] Update config/build-options.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- config/build-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/build-options.md b/config/build-options.md index 0e8deed1..1e0556c8 100644 --- a/config/build-options.md +++ b/config/build-options.md @@ -188,7 +188,7 @@ export default defineConfig({ ## build.license {#build-license} - **类型:** `boolean | { fileName?: string }` -- **默认:** `false`, +- **默认:** `false` - **相关:** [许可证](/guide/features#license) 当设置为 `true` 时,构建过程将生成一个 `.vite/license.md` 文件,其中包含所有打包依赖项的许可证信息。 From 4aa01b34adf4954b8c5aff98eadfee1d920c4e9a Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Fri, 7 Nov 2025 12:30:57 +0800 Subject: [PATCH 7/8] Update guide/static-deploy.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- guide/static-deploy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/static-deploy.md b/guide/static-deploy.md index 42902c16..685fe2e4 100644 --- a/guide/static-deploy.md +++ b/guide/static-deploy.md @@ -73,7 +73,7 @@ $ npm run preview 在你的仓库中创建一个新文件 `.github/workflows/deploy.yml`。你也可以从上一步点击 **"create your own"**,这将为你生成一个起始工作流程文件。 - 这里有一个示例工作流程,它使用 npm 安装依赖项,构建网站,并在你向 `main` 分支推送更改时部署它: + 这里有一个示例工作流程,它使用 npm 安装依赖项,构建网站,并在你向 `main` 分支推送更改时部署它: <<< ./static-deploy-github-pages.yaml#content [.github/workflows/deploy.yml] From 7574664fcac010b75f31d7fb2d0ad71458739278 Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Fri, 7 Nov 2025 12:32:41 +0800 Subject: [PATCH 8/8] Update guide/features.md --- guide/features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/features.md b/guide/features.md index ef912a05..9dee872d 100644 --- a/guide/features.md +++ b/guide/features.md @@ -790,7 +790,7 @@ import MyWorker from './worker?worker&url' 不要为 [`script-src`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src) 允许 `data:`。这将会允许注入任何脚本。 ::: -## license +## License Vite 可以通过 [`build.license`](/config/build-options.md#build-license) 选项生成一个包含构建中使用的所有依赖项许可证的文件。该文件可以被托管,用于显示和确认应用程序所使用的依赖项。