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

Switch to vercel #15

Merged
merged 9 commits into from
Nov 22, 2024
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
22 changes: 10 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Deploy to Netlify
name: Build and Deploy to Vercel

on:
push:
Expand All @@ -10,24 +10,22 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2

- name: Install pnpm
run: npm install -g pnpm

- name: Install dependencies
run: pnpm install

- name: Build Project
- name: Build
run: pnpm run build

- name: Deploy to Netlify
uses: nwtgck/[email protected]
- name: Deploy to Vercel
uses: BetaHuhn/deploy-to-vercel-action@v1
with:
publish-dir: ./dist
production-branch: main
deploy-message: ${{ github.event.head_commit.message }}
github-token: ${{ secrets.GH_TOKEN }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ You're all set!

## Discord Community

Feel free to join [IdeaDrawn Discord community](https://discord.gg/ideas) to find a place to connect with others. Anyone is welcome to strike a conversation, lurk, or give suggestions.
Feel free to join [IdeaDrawn Discord community](https://discord.gg/Up7E6gnkuy) to find a place to connect with others. Anyone is welcome to strike a conversation, lurk, or give suggestions.

## Contribution

Expand Down
23 changes: 23 additions & 0 deletions api/ssr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { renderPage } from "vite-plugin-ssr/server";

export default async function handler(req, res) {
const { url } = req;

if (!url) throw new Error("req.url is undefined");

const pageContextInit = { urlOriginal: url };
const pageContext = await renderPage(pageContextInit);
const { httpResponse } = pageContext;

if (!httpResponse) {
res.statusCode = 200;
res.end();
return;
}

const { body, statusCode, headers } = httpResponse;
console.log("Status code: ", statusCode);
res.statusCode = statusCode;
headers.forEach(([name, value]) => res.setHeader(name, value));
res.end(body);
}
13 changes: 2 additions & 11 deletions components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Lib
import logo from "../../assets/icons/IdeaDrawnNewLogo.png";
import { useState } from "react";
import Skeleton from "@mui/material/Skeleton";

// Types
import type { FC } from "react";
Expand All @@ -10,7 +9,7 @@ import type { FC } from "react";
import "./Footer.styles.css";

const Footer: FC = () => {
const [VERSION] = useState<string | null>("v1.0.0");
const [VERSION] = useState<string | null>("v0.0.1");

const MAINTAINER_URL = "https://github.com/MarkE16";
const REPO_URL = MAINTAINER_URL + "/LiveCanvas";
Expand Down Expand Up @@ -39,15 +38,7 @@ const Footer: FC = () => {
alt="logo"
/>
<span id="site-name">IdeaDrawn | Live Canvas</span>
<span id="version">
{VERSION ?? (
<Skeleton
sx={{ bgcolor: "grey.800" }}
variant="text"
width={50}
/>
)}
</span>
<span id="version">{VERSION}</span>
<span id="footer-text">
Made with ❤️ by{" "}
<a
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"dev": "npm run server:dev",
"prod": "npm run lint && npm run build && npm run server:prod",
"build": "vite build",
"serve": "vite preview",
"test": "vitest --run --silent --reporter=verbose",
"coverage": "vitest --coverage",
"server": "node --loader ts-node/esm ./server/index.ts",
Expand Down
8 changes: 8 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rewrites": [
{
"source": "/((?!assets/).*)",
"destination": "/api/ssr.js"
}
]
}
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { UserConfig } from "vite";

const config: UserConfig = {
plugins: [react(), ssr()],
build: {
outDir: "dist"
}
};

export default config;
Loading