From 41f3274271fcb6e7b53b8db9ad6d3753e1f48cd5 Mon Sep 17 00:00:00 2001 From: Patrick Rice Date: Thu, 2 Feb 2023 20:23:09 -0800 Subject: [PATCH 01/11] docs: fix typo in docs (#11918) --- guide/features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/features.md b/guide/features.md index 9ef89d3f..f32da8d1 100644 --- a/guide/features.md +++ b/guide/features.md @@ -34,7 +34,7 @@ Vite supports importing `.ts` files out of the box. Note that Vite only performs transpilation on `.ts` files and does **NOT** perform type checking. It assumes type checking is taken care of by your IDE and build process. -The reason Vite does not perform type checking as part of the transform process is because the two jobs work fundamentally differently. Transpilation can work on a per-file basis and aligns perfectly with Vite's on-demand compile model. In comparison, type checking quires knowledge of the entire module graph. Shoe-horning type checking into Vite's transform pipeline will inevitably compromise Vite's speed benefits. +The reason Vite does not perform type checking as part of the transform process is because the two jobs work fundamentally differently. Transpilation can work on a per-file basis and aligns perfectly with Vite's on-demand compile model. In comparison, type checking requires knowledge of the entire module graph. Shoe-horning type checking into Vite's transform pipeline will inevitably compromise Vite's speed benefits. Vite's job is to get your source modules into a form that can run in the browser as fast as possible. To that end, we recommend separating static analysis checks from Vite's transform pipeline. This principle applies to other static analysis checks such as ESLint. From fe98cd14b3d67d52b54b1939306d1a3302d48262 Mon Sep 17 00:00:00 2001 From: cmdcjones <43971640+cmdcjones@users.noreply.github.com> Date: Fri, 3 Feb 2023 16:04:11 -0500 Subject: [PATCH 02/11] docs: change wording in docs (#11933) --- guide/why.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/why.md b/guide/why.md index 6a868587..5938e7a6 100644 --- a/guide/why.md +++ b/guide/why.md @@ -33,7 +33,7 @@ import esmSvg from '../images/esm.svg?raw' ### Slow Updates -When a file is edited in a bundler-based build setup, it is inefficient to rebuild the whole bundle for obvious reasons: the update speed will degrade linearly with the size of the app. +When a file is edited in a bundler-based build setup, it is inefficient to rebuild the whole bundle for an obvious reason: the update speed will degrade linearly with the size of the app. In some bundlers, the dev server runs the bundling in memory so that it only needs to invalidate part of its module graph when a file changes, but it still needs to re-construct the entire bundle and reload the web page. Reconstructing the bundle can be expensive, and reloading the page blows away the current state of the application. This is why some bundlers support Hot Module Replacement (HMR): allowing a module to "hot replace" itself without affecting the rest of the page. This greatly improves DX - however, in practice we've found that even HMR update speed deteriorates significantly as the size of the application grows. From a498f4160681c8af048fa60f6a242f26a2f716f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Sat, 11 Feb 2023 22:48:09 +0100 Subject: [PATCH 03/11] docs: add mastodon docs (#12026) --- .vitepress/config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/.vitepress/config.ts b/.vitepress/config.ts index 956e4b30..98b0e7a6 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -106,6 +106,7 @@ export default defineConfig({ }, socialLinks: [ + { icon: 'mastodon', link: 'https://elk.zone/m.webtoo.ls/@vite' }, { icon: 'twitter', link: 'https://twitter.com/vite_js' }, { icon: 'discord', link: 'https://chat.vitejs.dev' }, { icon: 'github', link: 'https://github.com/vitejs/vite' }, From 966aa309ea5edc727f6e8c1bf6b81a90b10241ed Mon Sep 17 00:00:00 2001 From: Thiago Silveira Date: Mon, 13 Feb 2023 16:38:36 -0300 Subject: [PATCH 04/11] docs: fix migration guide link in vite v3 news (#12033) --- blog/announcing-vite3.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blog/announcing-vite3.md b/blog/announcing-vite3.md index 1baf096d..1f45fb8c 100644 --- a/blog/announcing-vite3.md +++ b/blog/announcing-vite3.md @@ -32,7 +32,7 @@ Today, 16 months from the v2 launch we are happy to announce the release of Vite Quick links: - [Docs](/) -- [Migration Guide](/guide/migration) +- [Migration Guide](https://v3.vitejs.dev/guide/migration.html) - [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#300-2022-07-13) If you are new to Vite, we recommend reading the [Why Vite Guide](https://vitejs.dev/guide/why.html). Then check out [the Getting Started](https://vitejs.dev/guide/) and [Features guide](https://vitejs.dev/guide/features) to see what Vite provides out of the box. As usual, contributions are welcome at [GitHub](https://github.com/vitejs/vite). More than [600 collaborators](https://github.com/vitejs/vite/graphs/contributors) have helped improve Vite so far. Follow the updates on [Twitter](https://twitter.com/vite_js), or join discussions with other Vite users on our [Discord chat server](http://chat.vitejs.dev/). @@ -193,7 +193,7 @@ There are other deploy scenarios where this isn't enough. For example, if the ge ### Esbuild Deps Optimization at Build Time (Experimental) -One of the main differences between dev and build time is how Vite handles dependencies. During build time, [`@rollup/plugin-commonjs`](https://github.com/rollup/plugins/tree/master/packages/commonjs) is used to allow importing CJS only dependencies (like React). When using the dev server, esbuild is used instead to pre-bundle and optimize dependencies, and an inline interop scheme is applied while transforming user code importing CJS deps. During the development of Vite 3, we introduced the changes needed to also allow the use of [esbuild to optimize dependencies during build time](/guide/migration.html#using-esbuild-deps-optimization-at-build-time). [`@rollup/plugin-commonjs`](https://github.com/rollup/plugins/tree/master/packages/commonjs) can then be avoided, making dev and build time work in the same way. +One of the main differences between dev and build time is how Vite handles dependencies. During build time, [`@rollup/plugin-commonjs`](https://github.com/rollup/plugins/tree/master/packages/commonjs) is used to allow importing CJS only dependencies (like React). When using the dev server, esbuild is used instead to pre-bundle and optimize dependencies, and an inline interop scheme is applied while transforming user code importing CJS deps. During the development of Vite 3, we introduced the changes needed to also allow the use of [esbuild to optimize dependencies during build time](https://v3.vitejs.dev/guide/migration.html#using-esbuild-deps-optimization-at-build-time). [`@rollup/plugin-commonjs`](https://github.com/rollup/plugins/tree/master/packages/commonjs) can then be avoided, making dev and build time work in the same way. Given that Rollup v3 will be out in the next months, and we're going to follow up with another Vite major, we've decided to make this mode optional to reduce v3 scope and give Vite and the ecosystem more time to work out possible issues with the new CJS interop approach during build time. Frameworks may switch to using esbuild deps optimization during build time by default at their own pace before Vite 4. @@ -211,7 +211,7 @@ Vite cares about its publish and install footprint; a fast installation of a new | Vite 3.0.0 | 3.05MB | 17.8MB | | Reduction | -30% | -7% | -In part, this reduction was possible by making some dependencies that most users weren't needing optional. First, [Terser](https://github.com/terser/terser) is no longer installed by default. This dependency was no longer needed since we already made esbuild the default minifier for both JS and CSS in Vite 2. If you use `build.minify: 'terser'`, you'll need to install it (`npm add -D terser`). We also moved [node-forge](https://github.com/digitalbazaar/forge) out of the monorepo, implementing support for automatic https certificate generation as a new plugin: [`@vitejs/plugin-basic-ssl`](/guide/migration.html#automatic-https-certificate-generation). Since this feature only creates untrusted certificates that are not added to the local store, it didn't justify the added size. +In part, this reduction was possible by making some dependencies that most users weren't needing optional. First, [Terser](https://github.com/terser/terser) is no longer installed by default. This dependency was no longer needed since we already made esbuild the default minifier for both JS and CSS in Vite 2. If you use `build.minify: 'terser'`, you'll need to install it (`npm add -D terser`). We also moved [node-forge](https://github.com/digitalbazaar/forge) out of the monorepo, implementing support for automatic https certificate generation as a new plugin: [`@vitejs/plugin-basic-ssl`](https://v3.vitejs.dev/guide/migration.html#automatic-https-certificate-generation). Since this feature only creates untrusted certificates that are not added to the local store, it didn't justify the added size. ## Bug Fixing @@ -228,7 +228,7 @@ A triaging marathon was spearheaded by [@bluwyoo](https://twitter.com/bluwyoo), - The Modern Browser Baseline now targets browsers which support the [native ES Modules](https://caniuse.com/es6-module), [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import), and [`import.meta`](https://caniuse.com/mdn-javascript_operators_import_meta) features. - JS file extensions in SSR and library mode now use a valid extension (`js`, `mjs`, or `cjs`) for output JS entries and chunks based on their format and the package type. -Learn more in the [Migration Guide](/guide/migration). +Learn more in the [Migration Guide](https://v3.vitejs.dev/guide/migration.html). ## Upgrades to Vite Core From b16e713a02d64c16bd67fd83898bb4428c198f1a Mon Sep 17 00:00:00 2001 From: Roman Kurbatov Date: Tue, 14 Feb 2023 11:55:56 +0200 Subject: [PATCH 05/11] docs(troubleshooting): add network stalled solution for ubuntu linux (fixes #11468) (#11959) --- guide/troubleshooting.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guide/troubleshooting.md b/guide/troubleshooting.md index 89827059..f97b0447 100644 --- a/guide/troubleshooting.md +++ b/guide/troubleshooting.md @@ -49,6 +49,8 @@ If the above steps don't work, you can try adding `DefaultLimitNOFILE=65536` as - /etc/systemd/system.conf - /etc/systemd/user.conf +For Ubuntu Linux, you may need to add the line `* - nofile 65536` to the file `/etc/security/limits.conf` instead of updating systemd config files. + Note that these settings persist but a **restart is required**. ### Network requests stop loading From 3fe3603e0d43a8f19e9332e0041609df3f5e22bd Mon Sep 17 00:00:00 2001 From: Doodles Date: Wed, 15 Feb 2023 10:29:33 -0300 Subject: [PATCH 06/11] docs: update GitHub Pages documentation (#12035) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 翠 / green Co-authored-by: Bjorn Lu --- guide/static-deploy.md | 90 +++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 36 deletions(-) diff --git a/guide/static-deploy.md b/guide/static-deploy.md index 5c2273b3..e1e2f32f 100644 --- a/guide/static-deploy.md +++ b/guide/static-deploy.md @@ -62,44 +62,62 @@ Now the `preview` command will launch the server at `http://localhost:8080`. If you are deploying to `https://.github.io//`, for example your repository is at `https://github.com//`, then set `base` to `'//'`. -2. Inside your project, create `deploy.sh` with the following content (with highlighted lines uncommented appropriately), and run it to deploy: - - ```bash{16,24,27} - #!/usr/bin/env sh - - # abort on errors - set -e - - # build - npm run build - - # navigate into the build output directory - cd dist - - # place .nojekyll to bypass Jekyll processing - echo > .nojekyll - - # if you are deploying to a custom domain - # echo 'www.example.com' > CNAME - - git init - git checkout -B main - git add -A - git commit -m 'deploy' - - # if you are deploying to https://.github.io - # git push -f git@github.com:/.github.io.git main - - # if you are deploying to https://.github.io/ - # git push -f git@github.com:/.git main:gh-pages - - cd - +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: + + ```yml + # Simple workflow for deploying static content to GitHub Pages + name: Deploy static content to Pages + + on: + # Runs on pushes targeting the default branch + push: + branches: ['main'] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + + # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages + permissions: + contents: read + pages: write + id-token: write + + # Allow one concurrent deployment + concurrency: + group: 'pages' + cancel-in-progress: true + + jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + - name: Install dependencies + run: npm install + - name: Build + run: npm run build + - name: Setup Pages + uses: actions/configure-pages@v3 + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + # Upload dist repository + path: './dist' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 ``` -::: tip -You can also run the above script in your CI setup to enable automatic deployment on each push. -::: - ## GitLab Pages and GitLab CI 1. Set the correct `base` in `vite.config.js`. From 4b4ef48a4a82ddc319e1887b143aeb00be407a4e Mon Sep 17 00:00:00 2001 From: ZhengX <56376387+Megrax@users.noreply.github.com> Date: Wed, 15 Feb 2023 21:54:54 +0800 Subject: [PATCH 07/11] docs: provider additional server proxy options (#11828) Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> --- config/server-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/server-options.md b/config/server-options.md index c6b884a2..d216bbed 100644 --- a/config/server-options.md +++ b/config/server-options.md @@ -83,7 +83,7 @@ Configure custom proxy rules for the dev server. Expects an object of `{ key: op Note that if you are using non-relative [`base`](/config/shared-options.md#base), you must prefix each key with that `base`. -Uses [`http-proxy`](https://github.com/http-party/node-http-proxy). Full options [here](https://github.com/http-party/node-http-proxy#options). +Extends [`http-proxy`](https://github.com/http-party/node-http-proxy#options). Additional options are [here](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/proxy.ts#L13). In some cases, you might also want to configure the underlying dev server (e.g. to add custom middlewares to the internal [connect](https://github.com/senchalabs/connect) app). In order to do that, you need to write your own [plugin](/guide/using-plugins.html) and use [configureServer](/guide/api-plugin.html#configureserver) function. From d13c3e024f6e26a511e477e245164d03c04fab6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Fri, 17 Feb 2023 00:17:14 +0900 Subject: [PATCH 08/11] docs: fix svg type override (#12078) --- guide/features.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/guide/features.md b/guide/features.md index f32da8d1..9ca69de2 100644 --- a/guide/features.md +++ b/guide/features.md @@ -113,16 +113,22 @@ This will provide the following type shims: - Types for the [HMR API](./api-hmr) on `import.meta.hot` ::: tip -To override the default typing, declare it before the triple-slash reference. For example, to make the default import of `*.svg` a React component: +To override the default typing, add a type definition file that contains your typings. Then, add the type reference before `vite/client`. -```ts -declare module '*.svg' { - const content: React.FC> - export default content -} +For example, to make the default import of `*.svg` a React component: -/// -``` +- `vite-env-override.d.ts` (the file that contains your typings): + ```ts + declare module '*.svg' { + const content: React.FC> + export default content + } + ``` +- The file containing the reference to `vite/client`: + ```ts + /// + /// + ``` ::: From c109bbe883097758c05717adfc1769c459eb5093 Mon Sep 17 00:00:00 2001 From: Noah <35386821+nmay231@users.noreply.github.com> Date: Fri, 17 Feb 2023 23:13:09 -0700 Subject: [PATCH 09/11] docs: link directly to Rollup 3 release notes (#12098) --- guide/migration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/migration.md b/guide/migration.md index c4e9c9b2..ec355c98 100644 --- a/guide/migration.md +++ b/guide/migration.md @@ -2,7 +2,7 @@ ## Rollup 3 -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). +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). Rollup 3 is mostly compatible with Rollup 2. If you are using custom [`rollupOptions`](../config/build-options.md#rollup-options) in your project and encounter issues, refer to the [Rollup migration guide](https://rollupjs.org/guide/en/#migration) to upgrade your config. From 229524eeb6264746d772796593453d1ac8acff03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Sat, 18 Feb 2023 11:52:12 +0100 Subject: [PATCH 10/11] docs: precise plugin-react-swc build when using plugins (#12020) --- plugins/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/index.md b/plugins/index.md index 4d502384..dd7cfce8 100644 --- a/plugins/index.md +++ b/plugins/index.md @@ -22,11 +22,11 @@ Check out [Using Plugins](../guide/using-plugins) for information on how to use ### [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react) -- Uses esbuild and Babel, achieving fast HMR with a small package footprint and the flexibility of being able to use the Babel transform pipeline. +- Uses esbuild and Babel, achieving fast HMR with a small package footprint and the flexibility of being able to use the Babel transform pipeline. Without additional Babel plugins, only esbuild is used during builds. ### [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) -- Uses esbuild during build, but replaces Babel with SWC during development. For big projects that don't require non-standard React extensions, cold start and Hot Module Replacement (HMR) can be significantly faster. +- Replaces Babel with SWC during development. During builds, SWC+esbuild are used when using plugins, and esbuild only otherwise. For big projects that don't require non-standard React extensions, cold start and Hot Module Replacement (HMR) can be significantly faster. ### [@vitejs/plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy) From 5ef11ddba52a532fb4c9f7b8f5b1ae48dcd1cb2a Mon Sep 17 00:00:00 2001 From: ShenQingchuan Date: Sun, 19 Feb 2023 22:46:33 +0800 Subject: [PATCH 11/11] docs(cn): resolve all conflicts --- config/server-options.md | 6 +---- guide/features.md | 12 ++------- guide/migration.md | 6 +---- guide/static-deploy.md | 55 +++++----------------------------------- guide/troubleshooting.md | 8 ++---- guide/why.md | 4 --- plugins/index.md | 12 ++------- 7 files changed, 15 insertions(+), 88 deletions(-) diff --git a/config/server-options.md b/config/server-options.md index 3190c459..efeae811 100644 --- a/config/server-options.md +++ b/config/server-options.md @@ -83,11 +83,7 @@ export default defineConfig({ 请注意,如果使用了非相对的 [基础路径 `base`](/config/shared-options.md#base),则必须在每个 key 值前加上该 `base`。 -<<<<<<< HEAD -使用 [`http-proxy`](https://github.com/http-party/node-http-proxy)。完整选项详见 [此处](https://github.com/http-party/node-http-proxy#options). -======= -Extends [`http-proxy`](https://github.com/http-party/node-http-proxy#options). Additional options are [here](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/proxy.ts#L13). ->>>>>>> 229524eeb6264746d772796593453d1ac8acff03 +继承自 [`http-proxy`](https://github.com/http-party/node-http-proxy#options)。完整选项详见 [此处](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/proxy.ts#L13). 在某些情况下,你可能也想要配置底层的开发服务器。(例如添加自定义的中间件到内部的 [connect](https://github.com/senchalabs/connect) 应用中)为了实现这一点,你需要编写你自己的 [插件](/guide/using-plugins.html) 并使用 [configureServer](/guide/api-plugin.html#configureserver) 函数。 diff --git a/guide/features.md b/guide/features.md index 62cf5408..07301775 100644 --- a/guide/features.md +++ b/guide/features.md @@ -34,11 +34,7 @@ Vite 天然支持引入 `.ts` 文件。 请注意,Vite 仅执行 `.ts` 文件的转译工作,**并不执行** 任何类型检查。并假定类型检查已经被你的 IDE 或构建过程处理了。 -<<<<<<< HEAD Vite 之所以不把类型检查作为转换过程的一部分,是因为这两项工作在本质上是不同的。转译可以在每个文件的基础上进行,与 Vite 的按需编译模式完全吻合。相比之下,类型检查需要了解整个模块图。把类型检查塞进 Vite 的转换管道,将不可避免地损害 Vite 的速度优势。 -======= -The reason Vite does not perform type checking as part of the transform process is because the two jobs work fundamentally differently. Transpilation can work on a per-file basis and aligns perfectly with Vite's on-demand compile model. In comparison, type checking requires knowledge of the entire module graph. Shoe-horning type checking into Vite's transform pipeline will inevitably compromise Vite's speed benefits. ->>>>>>> 229524eeb6264746d772796593453d1ac8acff03 Vite 的工作是尽可能快地将源模块转化为可以在浏览器中运行的形式。为此,我们建议将静态分析检查与 Vite 的转换管道分开。这一原则也适用于其他静态分析检查,例如 ESLint。 @@ -117,13 +113,9 @@ Vite 默认的类型定义是写给它的 Node.js API 的。要将其补充到 - `import.meta.hot` 上的 [HMR API](./api-hmr) 类型定义 ::: tip -<<<<<<< HEAD -要覆盖默认的类型定义,请在三斜线注释前添加定义。例如,要为 React 组件中的 `*.svg` 文件定义类型: -======= -To override the default typing, add a type definition file that contains your typings. Then, add the type reference before `vite/client`. ->>>>>>> 229524eeb6264746d772796593453d1ac8acff03 +要覆盖默认的类型定义,请添加一个包含你所定义类型的文件,请在三斜线注释 reference `vite/client` 前添加定义。 -For example, to make the default import of `*.svg` a React component: +例如,要为 React 组件中的 `*.svg` 文件定义类型: - `vite-env-override.d.ts` (the file that contains your typings): ```ts diff --git a/guide/migration.md b/guide/migration.md index 81a9b3da..4cd302f9 100644 --- a/guide/migration.md +++ b/guide/migration.md @@ -2,11 +2,7 @@ ## Rollup 3 {#rollup-3} -<<<<<<< HEAD -Vite 现在正式启用 [Rollup 3](https://github.com/vitejs/vite/issues/9870),这使得我们可以简化 Vite 内部的资源处理并同时拥有许多改进。详情请查看 [Rollup 3 版本记录](https://github.com/rollup/rollup/releases)。 -======= -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). ->>>>>>> 229524eeb6264746d772796593453d1ac8acff03 +Vite 现在正式启用 [Rollup 3](https://github.com/vitejs/vite/issues/9870),这使得我们可以简化 Vite 内部的资源处理并同时拥有许多改进。详情请查看 [Rollup 3 版本记录](https://github.com/rollup/rollup/releases/tag/v3.0.0)。 Rollup 3 尽最大可能兼容了 Rollup 2。如果你在项目中使用了自定义的 [`rollupOptions`](../config/build-options.md#rollup-options) 并(升级后)遇到了问题,请先查看 [Rollup 迁移指南](https://rollupjs.org/guide/en/#migration) 来更新升级你的配置。 diff --git a/guide/static-deploy.md b/guide/static-deploy.md index df4db864..3fd126f2 100644 --- a/guide/static-deploy.md +++ b/guide/static-deploy.md @@ -62,73 +62,33 @@ $ npm run preview 如果你要部署在 `https://.github.io//` 上,例如你的仓库地址为 `https://github.com//`,那么请设置 `base` 为 `'//'`。 -<<<<<<< HEAD 2. 在你的项目中,创建一个 `deploy.sh` 脚本,包含以下内容(注意高亮的行,按需使用),运行脚本来部署站点: -======= -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: ->>>>>>> 229524eeb6264746d772796593453d1ac8acff03 ```yml # Simple workflow for deploying static content to GitHub Pages name: Deploy static content to Pages -<<<<<<< HEAD - # 发生错误时终止 - set -e - - # 构建 - npm run build - - # 进入构建文件夹 - cd dist - - # 放置 .nojekyll 以绕过 Jekyll 的处理。 - echo > .nojekyll - - # 如果你要部署到自定义域名 - # echo 'www.example.com' > CNAME - - git init - git checkout -B main - git add -A - git commit -m 'deploy' - - # 如果你要部署在 https://.github.io - # git push -f git@github.com:/.github.io.git main - - # 如果你要部署在 https://.github.io/ - # git push -f git@github.com:/.git main:gh-pages - - cd - - ``` - -::: tip -你也可以在你的 CI 中配置该脚本,使得在每次推送代码时自动部署。 -::: - -## GitLab Pages 配合 GitLab CI {#gitlab-pages-and-gitlab-ci} -======= on: - # Runs on pushes targeting the default branch + # 仅在推送到默认分支时运行。 push: branches: ['main'] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + # 这个选项可以使你手动在 Action tab 页面触发工作流 + workflow_dispatch: - # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages + # 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages。 permissions: contents: read pages: write id-token: write - # Allow one concurrent deployment + # 允许一个并发的部署 concurrency: group: 'pages' cancel-in-progress: true jobs: - # Single deploy job since we're just deploying + # 单次部署的工作描述 deploy: environment: name: github-pages @@ -158,8 +118,7 @@ $ npm run preview uses: actions/deploy-pages@v1 ``` -## GitLab Pages and GitLab CI ->>>>>>> 229524eeb6264746d772796593453d1ac8acff03 +## GitLab Pages 配合 GitLab CI {#gitlab-pages-and-gitlab-ci} 1. 在 `vite.config.js` 中设置正确的 `base`。 diff --git a/guide/troubleshooting.md b/guide/troubleshooting.md index 15ee127a..12c744a5 100644 --- a/guide/troubleshooting.md +++ b/guide/troubleshooting.md @@ -49,13 +49,9 @@ - /etc/systemd/system.conf - /etc/systemd/user.conf -<<<<<<< HEAD -请注意,这些配置会持久作用,但需要 **重新启动**。 -======= -For Ubuntu Linux, you may need to add the line `* - nofile 65536` to the file `/etc/security/limits.conf` instead of updating systemd config files. +对于 Ubuntu Linux 操作系统,你可能需要添加一行 `* - nofile 65536` 到文件 `/etc/security/limits.conf` 之中,而不是更新 systemd 配置文件。 -Note that these settings persist but a **restart is required**. ->>>>>>> 229524eeb6264746d772796593453d1ac8acff03 +请注意,这些配置会持久作用,但需要 **重新启动**。 ### 网络请求停止加载 {#network-requests-stop-loading} diff --git a/guide/why.md b/guide/why.md index e1c7c4b1..1e35b662 100644 --- a/guide/why.md +++ b/guide/why.md @@ -33,11 +33,7 @@ import esmSvg from '../images/esm.svg?raw' ### 缓慢的更新 {#slow-updates} -<<<<<<< HEAD 基于打包器启动时,重建整个包的效率很低。原因显而易见:因为这样更新速度会随着应用体积增长而直线下降。 -======= -When a file is edited in a bundler-based build setup, it is inefficient to rebuild the whole bundle for an obvious reason: the update speed will degrade linearly with the size of the app. ->>>>>>> 229524eeb6264746d772796593453d1ac8acff03 一些打包器的开发服务器将构建内容存入内存,这样它们只需要在文件更改时使模块图的一部分失活[[1]](#footnote-1),但它也仍需要整个重新构建并重载页面。这样代价很高,并且重新加载页面会消除应用的当前状态,所以打包器支持了动态模块热替换(HMR):允许一个模块 “热替换” 它自己,而不会影响页面其余部分。这大大改进了开发体验 —— 然而,在实践中我们发现,即使采用了 HMR 模式,其热更新速度也会随着应用规模的增长而显著下降。 diff --git a/plugins/index.md b/plugins/index.md index 7763548b..02792b0d 100644 --- a/plugins/index.md +++ b/plugins/index.md @@ -22,19 +22,11 @@ Vite 旨在为常见的 web 开发工作提供开箱即用的支持。在搜索 ### [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react) -<<<<<<< HEAD -- 使用 esbuild 和 Babel,提供极速的 HMR 和一个微小体积的包脚注,同时提升灵活性,能够使用 Babel 的转换管线。 -======= -- Uses esbuild and Babel, achieving fast HMR with a small package footprint and the flexibility of being able to use the Babel transform pipeline. Without additional Babel plugins, only esbuild is used during builds. ->>>>>>> 229524eeb6264746d772796593453d1ac8acff03 +- 使用 esbuild 和 Babel,使用一个微小体积的包脚注可以实现极速的 HMR,同时提升灵活性,能够使用 Babel 的转换管线。在构建时没有使用额外的 Babel 插件,只使用了 esbuild。 ### [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) {#vitejsplugin-react-swc} -<<<<<<< HEAD -- 在构建时使用 esbuild,但会在开发时使用 SWC 替换 Babel。对不需要标准 React 扩展的大型项目,冷启动和模块热替换(HMR)将会有显著提升。 -======= -- Replaces Babel with SWC during development. During builds, SWC+esbuild are used when using plugins, and esbuild only otherwise. For big projects that don't require non-standard React extensions, cold start and Hot Module Replacement (HMR) can be significantly faster. ->>>>>>> 229524eeb6264746d772796593453d1ac8acff03 +- 在开发时会将 Babel 替换为 SWC。在构建时,若使用了插件则会使用 SWC+esbuild,若没有使用插件则仅会用到 esbuild。对不需要标准 React 扩展的大型项目,冷启动和模块热替换(HMR)将会有显著提升。 ### [@vitejs/plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy) {#vitejsplugin-legacy}