aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/ecosystem/vite.md
blob: 857e11aae65d10b32c20c18034072cc776a0565f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
name: Build a frontend using Vite and Bun
---

{% callout %}
While Vite currently works with Bun, it has not been heavily optimized, nor has Vite been adapted to use Bun's bundler, module resolver, or transpiler.
{% /callout %}

---

Vite works out of the box with Bun (v0.7 and later). Get started with one of Vite's templates.

```bash
$ bunx create-vite my-app
✔ Select a framework: › React
✔ Select a variant: › TypeScript + SWC
Scaffolding project in /path/to/my-app...
```

---

Then `cd` into the project directory and install dependencies.

```bash
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](<https://en.wikipedia.org/wiki/Shebang_(Unix)>). After Bun 1.0 this flag will no longer be necessary.

```bash
bunx --bun vite
```

---

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

```json-diff#package.json
  "scripts": {
-   "dev": "vite",
+   "dev": "bunx --bun vite",
    "build": "vite build",
    "serve": "vite preview"
  },
  // ...
```

---

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

```bash
bun run dev
```

---

The following command will build your app for production.

```sh
$ bunx --bun vite build
```

---

This is a stripped down guide to get you started with Vite + Bun. For more information, see the [Vite documentation](https://vitejs.dev/guide/).
'deletions'>-62/+83 2022-08-21Add a binding for creating atomic stringsGravatar Jarred Sumner 5-2/+37 2022-08-21Slightly optimize escapeHTMLescapeHTML8 & escapeHTML16Gravatar Jarred Sumner 2-80/+134 2022-08-20Update WebKitGravatar Jarred Sumner 1-0/+0 2022-08-20Export `createSyntheticModule`Gravatar Jarred Sumner 3-1/+22 2022-08-20wip support #!Gravatar Jarred Sumner 1-1/+6 2022-08-20fix(ReferenceError): expected type in getCode (#1120)Gravatar Hyro 1-1/+1 2022-08-20Fix running zig testsGravatar Jarred Sumner 1-3/+10 2022-08-20Fix crash on invalid JSXGravatar Jarred Sumner 1-1/+1 2022-08-20Add `code` to `ResolveError`Gravatar Jarred Sumner 1-0/+14 2022-08-20Add buffer.indexOf, includes and lastIndexOf (#1112)Gravatar Zilin Zhu 2-32/+237 2022-08-19fix buffer.slice(0, 0) (#1114)Gravatar Zilin Zhu 23-27/+58 2022-08-19fix buffer.copy (#1113)Gravatar Zilin Zhu 2-21/+35 2022-08-19Update build-idGravatar Jarred Sumner 1-1/+1 2022-08-19Make React SSR up to 3x fasterGravatar Jarred Sumner 1-238/+247 2022-08-192x faster `Bun.serve` with async function handlersGravatar Jarred Sumner 1-4/+13 2022-08-19Update bun init testbun-v0.1.10Gravatar Jarred Sumner 1-2/+2 2022-08-18Synchronously dispatch `close` eventGravatar Jarred Sumner 1-0/+5 2022-08-18Fix memory leak in `WebSocket`Gravatar Jarred Sumner 1-13/+4 2022-08-18Make `Request`, `Response` and `TextDecoder` not read-onlyGravatar Jarred Sumner 7-120/+180 2022-08-18Update build-idGravatar Jarred Sumner 1-1/+1 2022-08-18un-delete some codeGravatar Jarred Sumner 2-8/+15 2022-08-18Add string support to `Buffer.fill`Gravatar Jarred Sumner 7-77/+119 2022-08-18[node compat] Fix issue with `Buffer.compare` when called on the constructorGravatar Jarred Sumner 1-31/+42 2022-08-18Fix console.log printing `[native code]` for too many thingsGravatar Jarred Sumner 1-1/+6 2022-08-18Faster TextDecoderGravatar Jarred Sumner 24-369/+399 2022-08-18Fix Next.js regressionGravatar Jarred Sumner 1-12/+45 2022-08-18Fix `bun:wrap` not loadingGravatar Jarred Sumner 3-21/+41