Vite

Vite 是一个构建工具,旨在为现代 Web 项目提供更快、更精简的开发体验。

¥Vite is a build tool that aims to provide a faster and leaner development experience for modern web projects.

快速入门

¥Quickstart

要在 Turborepo 中快速开始使用 Vite,请使用 with-vite 示例

¥To get started with Vite in a Turborepo quickly, use the with-vite example:

Terminal
pnpm dlx create-turbo@latest -e with-vite

将 Vite 应用添加到现有仓库

¥Adding a Vite application to an existing repository

使用 npm create vite 在包中设置新的 Vite 应用。从你的代码库根目录运行:

¥Use npm create vite to set up a new Vite application in a package. From the root of your repository, run:

Terminal
pnpm create vite@latest apps/my-app

与你的仓库集成

¥Integrating with your repository

要将 内部软件包 添加到你的新应用,请使用你的包管理器将其安装到应用中:

¥To add Internal Packages to your new application, install them into the app with your package manager:

./apps/my-app/package.json
{
  "name": "my-app",
  "dependencies": {
+   "@repo/ui": "workspace:*"
  }
}

确保运行包管理器的安装命令。你可能还需要在 package.json 中更新 scripts,以适应你的代码库中的用例。

¥Make sure to run your package manager's install command. You also may need to update scripts in package.json to fit your use case in your repository.

自定义任务

¥Customizing tasks

默认情况下,新应用将使用根 turbo.json 中定义的任务。如果你想为新应用配置不同的任务,请使用 软件包配置

¥By default, the new application will use the tasks defined in the root turbo.json. If you'd like to configure tasks differently for the new application, use Package Configurations.