Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use vercel preset #82

Merged
merged 4 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .tests/test.vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test("dev", async ({ page, $ }) => {
const port = await getPort();
const dev = $(`pnpm dev`, { env: { PORT: String(port) } });

const url = await matchLine(dev.stdout, urlRegex.custom);
const url = await matchLine(dev.stdout, urlRegex.viteDev);
await workflow({ page, url });
expect(withoutHmrPortError(dev.buffer.stderr)).toBe("");
});
Expand Down
379 changes: 315 additions & 64 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vercel/app/routes/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function meta({}: Route.MetaArgs) {
}

export function loader({ context }: Route.LoaderArgs) {
return { message: context.VALUE_FROM_VERCEL };
return { message: "Hello from Vercel" };
}

export default function Home({ loaderData }: Route.ComponentProps) {
Expand Down
29 changes: 0 additions & 29 deletions vercel/dev-server.js

This file was deleted.

18 changes: 8 additions & 10 deletions vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,26 @@
"private": true,
"type": "module",
"scripts": {
"build": "react-router build && node vercel/prepare.js",
"dev": "cross-env NODE_ENV=development node ./dev-server.js",
"build": "react-router build",
"dev": "react-router dev",
"start": "react-router-serve ./build/server/index.js",
"typecheck": "react-router typegen && tsc"
},
"dependencies": {
"@react-router/express": "*",
"@react-router/node": "*",
"@vercel/node": "^3.2.25",
"express": "^4.21.1",
"@react-router/node": "^7.1.5",
"isbot": "^5.1.17",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router": "*"
"react-router": "^7.1.5"
},
"devDependencies": {
"@react-router/dev": "*",
"@react-router/dev": "^7.1.5",
"@tailwindcss/vite": "^4.0.0",
"@types/express": "^5.0.0",
"@types/node": "^20",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.1",
"cross-env": "^7.0.3",
"@vercel/node": "^5.1.2",
"@vercel/react-router": "^1.0.2",
"tailwindcss": "^4.0.0",
"typescript": "^5.7.2",
"vite": "^5.4.11",
Expand Down
2 changes: 2 additions & 0 deletions vercel/react-router.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { Config } from "@react-router/dev/config";
import { vercelPreset } from "@vercel/react-router/vite";

export default {
// Config options...
// Server-side render by default, to enable SPA mode set this to `false`
ssr: true,
presets: [vercelPreset()],
} satisfies Config;
25 changes: 0 additions & 25 deletions vercel/server/app.ts

This file was deleted.

20 changes: 0 additions & 20 deletions vercel/vercel/output/config.json

This file was deleted.

6 changes: 0 additions & 6 deletions vercel/vercel/output/functions/index.func/.vc-config.json

This file was deleted.

3 changes: 0 additions & 3 deletions vercel/vercel/output/functions/index.func/package.json

This file was deleted.

10 changes: 0 additions & 10 deletions vercel/vercel/prepare.js

This file was deleted.

9 changes: 1 addition & 8 deletions vercel/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig(({ isSsrBuild, command }) => ({
build: {
rollupOptions: isSsrBuild
? {
input: "./server/app.ts",
}
: undefined,
},
export default defineConfig(({ command }) => ({
ssr: {
noExternal: command === "build" ? true : undefined,
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if it's necessary, I wasn't quite sure what it was for in the first place so I've left it alone

Expand Down