vite-plus README

项目的 README,来自 github.com/voidzero-dev/vite-plus。合并为一个 markdown 文件:README.md。

Vite+ Vite+

The Unified Toolchain for the Web runtime and package management, create, dev, check, test, build, pack, and monorepo task caching in a single dependency


Vite+ is the unified entry point for local web development. It combines Vite, Vitest, Oxlint, Oxfmt, Rolldown, tsdown, and Vite Task into one zero-config toolchain that also manages runtime and package manager workflows:

All of this is configured from your project root and works across Vite's framework ecosystem. Vite+ is fully open-source under the MIT license.

Getting Started

Install Vite+ globally as vp:

For Linux or macOS:

curl -fsSL https://vite.plus | bash

For Windows:

irm https://viteplus.dev/install.ps1 | iex

vp handles the full development lifecycle such as package management, development servers, linting, formatting, testing and building for production.

Configuring Vite+

Vite+ can be configured using a single vite.config.ts at the root of your project:

import { defineConfig } from 'vite-plus';

export default defineConfig({
  // Standard Vite configuration for dev/build/preview.
  plugins: [],

  // Vitest configuration.
  test: {
    include: ['src/**/*.test.ts'],
  },

  // Oxlint configuration.
  lint: {
    ignorePatterns: ['dist/**'],
  },

  // Oxfmt configuration.
  fmt: {
    semi: true,
    singleQuote: true,
  },

  // Vite Task configuration.
  run: {
    tasks: {
      'generate:icons': {
        command: 'node scripts/generate-icons.js',
        cache: {
          env: ['ICON_THEME'],
        },
      },
    },
  },

  // `vp staged` configuration.
  staged: {
    '*': 'vp check --fix',
  },
});

This lets you keep the configuration for your development server, build, test, lint, format, task runner, and staged-file workflow in one place with type-safe config and shared defaults.

Use vp migrate to migrate to Vite+. It merges tool-specific config files such as .oxlintrc*, .oxfmtrc*, and lint-staged config into vite.config.ts.

CLI Workflows (vp help)

Start

Develop

Execute

Build

Manage Dependencies

Vite+ automatically wraps your package manager (pnpm, npm, Yarn, or Bun) based on packageManager and lockfiles:

Maintain

Scaffolding your first Vite+ project

Use vp create to create a new project:

vp create

You can run vp create inside of a project to add new apps or libraries to your project.

Organizations can expose a curated set of templates under their npm scope by publishing @org/create with a createConfig.templates manifest in its package.json. Once published, vp create @org opens an interactive picker over those templates, and setting create: { defaultTemplate: '@org' } in vite.config.ts makes it the default for bare vp create. See the Organization Templates guide for the authoring workflow and create.defaultTemplate for the config reference.

Migrating an existing project

You can migrate an existing project to Vite+:

vp migrate

GitHub Actions

Use the official setup-vp action to install Vite+ in GitHub Actions:

- uses: voidzero-dev/setup-vp@<setup-vp-version>
  with:
    node-version: '22'
    cache: true

Set <setup-vp-version> to an exact version from the setup-vp releases page. You can use a commit SHA instead. Do not use the v1 tag. The v1 tag no longer receives updates.

See Automatic Version Updates to configure Dependabot or Renovate.

Manual Installation & Migration

If you are manually migrating a project to Vite+, install these dev dependencies first:

vp install -D vite-plus

Add package-manager overrides so that other packages use the Vite+ versions. Alias vite to @voidzero-dev/vite-plus-core, setting <core-version> to the core version that the installed vite-plus uses, shown by vp toolchain vite-plus-core. The core version encodes the bundled Vite version (for example, 8.3.5000 for Vite 8.3.5), so package managers check vite peer ranges against the bundled Vite. Pin vitest to <vitest-version>, using the bundled version shown by vp toolchain vitest. The project and vp test then use the same Vitest copy. Without the pin, a dependency or workspace package can install a different Vitest version. The two versions can use separate mocks, expect functions, and runner states:

"overrides": {
  "vite": "npm:@voidzero-dev/vite-plus-core@<core-version>",
  "vitest": "<vitest-version>"
}

If you are using pnpm, add this to your pnpm-workspace.yaml:

overrides:
  vite@*: npm:@voidzero-dev/vite-plus-core@<core-version> # Match the version from vp toolchain vite-plus-core
  vitest@*: <vitest-version> # Match the version from vp toolchain vitest

Or, if you are using Yarn:

"resolutions": {
  "vite": "npm:@voidzero-dev/vite-plus-core@<core-version>",
  "vitest": "<vitest-version>"
}

Sponsors

Thanks to namespace.so for powering our CI/CD pipelines with fast, free macOS, Linux, and Windows runners.

vite-plus (voidzero-dev/vite-plus)

正在搜索数据库…

这是什么?Vite+ 是 Web 开发的统一工具链和入口:它是一个零配置的单一命令行工具(vp),整合了 Vite、Vitest、Oxlint、Oxfmt、Rolldown、tsdown 和任务运行器,还负责管理你的 Node.js 运行时和包管理器。
它是框架,还是只是对其他工具的命令行封装?它是一个命令行工具(vp 可执行文件),封装并协调 Vite、Vitest、Oxlint、Oxfmt、Rolldown、tsdown 等现有工具,而不是你需要在代码中调用的框架。
我怎样才能让 vp 运行起来?你需要全局安装 Vite+:Linux/macOS 使用一条命令,Windows 使用另一条单独的命令。安装后即可获得 vp 命令行工具,用于开发、构建、测试、代码检查等。
我需要先自己安装 Node.js 和包管理器吗?不需要。vp env 会为你管理 Node.js 和包管理器;vp 还会根据 packageManager 字段和锁文件,自动封装你项目所用的包管理器(pnpm、npm、Yarn 或 Bun)。
手动迁移现有项目而不使用 vp migrate 时有哪些需要注意的坑?你需要把 vite 别名指向 @voidzero-dev/vite-plus-core,并将 vitest 固定为 Vite+ 所打包的确切版本(可通过 vp toolchain vitest 查看)。否则某个依赖可能会引入另一份 Vitest 副本,它们的 mock、expect 函数和运行器状态各自独立,从而导致隐蔽的测试错误。
如何一次性配置所有这些工具?所有配置都集中在项目根目录下的单个 vite.config.ts 文件中,为开发服务器、构建、测试、代码检查、格式化、任务运行器和暂存文件工作流提供类型安全的共享配置。
如何将现有项目迁移到 Vite+?运行 vp migrate;它会把 .oxlintrc、.oxfmtrc 和 lint-staged 配置等各工具专用的配置文件合并到单个 vite.config.ts 中。
如何搭建一个全新的项目?使用 vp create 选择模板;组织也可以在某个 npm 作用域(例如 @org/create)下发布自己精选的模板,并通过 vp create @org 提供给使用者。
我能在 CI/CD 中使用 Vite+ 吗?可以。官方的 setup-vp GitHub Action 可在 GitHub Actions 中安装 Vite+;建议将其固定到确切的版本号或提交 SHA,因为 v1 标签已不再接收更新。
有哪些类似的项目?oxc, nub, closure-compiler, bun, nx, woocommerce, rolldown, pnpm
大小
40.1 MB
星标
6.6K
时长
1年
提交 · 90 天