From bba9ec96e582a8b830fe85849b5a9414f25613a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Moreau?= Date: Thu, 28 Nov 2024 10:37:16 +0100 Subject: [PATCH] add doc for package scripts (#21) --- README.md | 36 +++++++++++++++++-- examples/react-router-bun/package.json | 2 +- .../react-router-custom-build/package.json | 2 +- .../react-router-custom-https/package.json | 2 +- examples/react-router-sentry/package.json | 2 +- examples/react-router-virtual/package.json | 2 +- 6 files changed, 39 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 23a6022..158279e 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,7 @@ Use the `serverEntryPoint` option of the Vite plugin `reactRouterHonoServer` to ### Update your package.json scripts +### Node It is not an error, you can keep the React Router defaults for `build` and `dev`! ```json "scripts": { @@ -218,6 +219,37 @@ It is not an error, you can keep the React Router defaults for `build` and `dev` "start": "node ./build/server/index.js", }, ``` +### Bun +It is not an error, you can keep the React Router defaults for `build`! +```json + "scripts": { + "build": "react-router build", + "dev": "bunx --bun vite", + "start": "bun ./build/server/index.js", + }, +``` + +### Cloudflare +It is not an error, you can keep the React Router defaults for `build` and `dev`! +```json + "scripts": { + "build": "react-router build", + "dev": "react-router dev", + "start": "wrangler dev", + }, +``` + +#### Wrangler +Add a file named `wrangler.toml` at the root of your project (close to `package.json`). + +Adapt the `main` and `assets` fields based on your build output, if you changed them from the defaults. +```toml +workers_dev = true +name = "my-worker" +compatibility_date = "2024-11-18" +main = "./build/server/index.js" +assets = { directory = "./build/client/" } +``` ## How it works @@ -231,7 +263,7 @@ You can customize the production server port using the `port` option of `createH When building for production, the Hono server is compiled as `build/server/index.js` and imports your React Router app from `assets/server-build-[hash].js`. -To run the server in production, use `NODE_ENV=production node ./build/server/index.js`. +To run the server in production, use `node ./build/server/index.js`. That's all! @@ -568,7 +600,7 @@ If you used a custom `buildDirectory` option, check this [example](./examples/re "scripts": { "build": "react-router build", "dev": "react-router dev", - "start": "NODE_ENV=production node ./build/server/index.js", + "start": "node ./build/server/index.js", }, ``` diff --git a/examples/react-router-bun/package.json b/examples/react-router-bun/package.json index 13e5072..c003546 100644 --- a/examples/react-router-bun/package.json +++ b/examples/react-router-bun/package.json @@ -7,7 +7,7 @@ "build": "react-router build", "dev": "bunx --bun vite", "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "NODE_ENV=production bun ./build/server/index.js", + "start": "bun ./build/server/index.js", "typecheck": "react-router typegen && tsc" }, "dependencies": { diff --git a/examples/react-router-custom-build/package.json b/examples/react-router-custom-build/package.json index 984b146..5a6b590 100644 --- a/examples/react-router-custom-build/package.json +++ b/examples/react-router-custom-build/package.json @@ -7,7 +7,7 @@ "build": "react-router build", "dev": "react-router dev", "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "NODE_ENV=production node ./dist/server/index.js", + "start": "node ./dist/server/index.js", "typecheck": "react-router typegen && tsc" }, "dependencies": { diff --git a/examples/react-router-custom-https/package.json b/examples/react-router-custom-https/package.json index 8eed28d..72bf84e 100644 --- a/examples/react-router-custom-https/package.json +++ b/examples/react-router-custom-https/package.json @@ -7,7 +7,7 @@ "build": "react-router build", "dev": "react-router dev", "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "NODE_ENV=production node ./build/server/index.js", + "start": "node ./build/server/index.js", "typecheck": "react-router typegen && tsc" }, "dependencies": { diff --git a/examples/react-router-sentry/package.json b/examples/react-router-sentry/package.json index d00c95d..2a45ffd 100644 --- a/examples/react-router-sentry/package.json +++ b/examples/react-router-sentry/package.json @@ -7,7 +7,7 @@ "build": "react-router build", "dev": "react-router dev", "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "NODE_ENV=production node ./build/server/index.js", + "start": "node ./build/server/index.js", "typecheck": "react-router typegen && tsc" }, "dependencies": { diff --git a/examples/react-router-virtual/package.json b/examples/react-router-virtual/package.json index 9097548..4590a2f 100644 --- a/examples/react-router-virtual/package.json +++ b/examples/react-router-virtual/package.json @@ -7,7 +7,7 @@ "build": "react-router build", "dev": "react-router dev", "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "NODE_ENV=production node ./build/server/index.js", + "start": "node ./build/server/index.js", "typecheck": "react-router typegen && tsc" }, "dependencies": {