Skip to main content

Build a frontend using Vite and Bun

还没翻译译自英文(bun.com)本页 10 段都还没译

Note

You can use Vite with Bun, but many projects get faster builds & drop hundreds of dependencies by switching to HTML imports.


Vite works with Bun with no extra configuration. Get started with one of Vite's templates.

bun create vite my-app
◇  Select a framework:
│  React
│
◇  Select a variant:
│  TypeScript
│
◇  Which linter to use?
│  Oxlint
│
◇  Install with bun and start now?
│  No
│
◇  Scaffolding project in /path/to/my-app...

Then cd into the project directory and install dependencies.

cd my-app
bun install

Start the development server with the vite CLI using bunx.

The --bun flag tells Bun to run Vite's CLI using bun instead of node. By default, Bun respects Vite's #!/usr/bin/env node shebang line.

bunx --bun vite

To simplify this command, update the "dev" script in package.json to the following.

  "scripts": {
    "dev": "vite",
    "dev": "bunx --bun vite",
    "build": "tsc -b && vite build",
    "lint": "oxlint",
    "preview": "vite preview"
  },
  // ...

Now you can start the development server with bun run dev.

bun run dev

Build your app for production.

bunx --bun vite build

For more information, see the Vite documentation.

번역 © 2026 fanyi.dev · 원문 © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)