aboutsummaryrefslogtreecommitdiff
path: root/docs/dev/cra.md
diff options
context:
space:
mode:
authorGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-02-23 17:13:30 -0800
committerGravatar GitHub <noreply@github.com> 2023-02-23 17:13:30 -0800
commitf54300578b1edc7f67daddbfae29575cbf305264 (patch)
tree1437f3274122c011f879dca71f59a74d75a33fd0 /docs/dev/cra.md
parent5929daeeae1f528abab31979a0a28bc87a03b1f4 (diff)
downloadbun-f54300578b1edc7f67daddbfae29575cbf305264.tar.gz
bun-f54300578b1edc7f67daddbfae29575cbf305264.tar.zst
bun-f54300578b1edc7f67daddbfae29575cbf305264.zip
Add documentation (#2148)bun-v0.5.7
* Add documentation * Tweaks * Fixes * Rearrange * Update
Diffstat (limited to 'docs/dev/cra.md')
-rw-r--r--docs/dev/cra.md31
1 files changed, 31 insertions, 0 deletions
diff --git a/docs/dev/cra.md b/docs/dev/cra.md
new file mode 100644
index 000000000..8eb868715
--- /dev/null
+++ b/docs/dev/cra.md
@@ -0,0 +1,31 @@
+To create a new React app:
+
+```bash
+$ bun create react ./app
+$ cd app
+$ bun dev # start dev server
+```
+
+To use an existing React app:
+
+```bash
+$ bun add -d react-refresh # install React Fast Refresh
+$ bun bun ./src/index.js # generate a bundle for your entry point(s)
+$ bun dev # start the dev server
+```
+
+From there, Bun relies on the filesystem for mapping dev server paths to source files. All URL paths are relative to the project root (where `package.json` is located).
+
+Here are examples of routing source code file paths:
+
+| Dev Server URL | File Path (relative to cwd) |
+| -------------------------- | --------------------------- |
+| /src/components/Button.tsx | src/components/Button.tsx |
+| /src/index.tsx | src/index.tsx |
+| /pages/index.js | pages/index.js |
+
+You do not need to include file extensions in `import` paths. CommonJS-style import paths without the file extension work.
+
+You can override the public directory by passing `--public-dir="path-to-folder"`.
+
+If no directory is specified and `./public/` doesn’t exist, Bun will try `./static/`. If `./static/` does not exist, but won’t serve from a public directory. If you pass `--public-dir=./` Bun will serve from the current directory, but it will check the current directory last instead of first.