From eccb00f302a33fecde8817c0fcdfc71bc7fa86b8 Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Thu, 29 Jun 2023 22:27:25 +0900 Subject: [PATCH 1/2] =?UTF-8?q?:wrench:=20@t3-oss/env-nextjs=20=E3=81=A8?= =?UTF-8?q?=20zod=20=E3=81=AE=E5=B0=8E=E5=85=A5=20(#113)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/frontend/package.json | 4 +++- pnpm-lock.yaml | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/apps/frontend/package.json b/apps/frontend/package.json index cf0dcc02..bac75112 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -25,6 +25,7 @@ "@radix-ui/react-dropdown-menu": "^2.0.5", "@radix-ui/react-icons": "^1.3.0", "@tailwindcss/line-clamp": "0.4.4", + "@t3-oss/env-nextjs": "^0.6.0", "@types/react-syntax-highlighter": "15.5.7", "@vercel/analytics": "^1.0.1", "clsx": "1.2.1", @@ -39,7 +40,8 @@ "react-hook-form": "7.45.1", "react-markdown": "8.0.7", "react-syntax-highlighter": "15.5.0", - "recoil": "0.7.7" + "recoil": "0.7.7", + "zod": "^3.21.4" }, "devDependencies": { "@babel/core": "7.22.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6536983a..dcebb424 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -114,6 +114,9 @@ importers: '@radix-ui/react-icons': specifier: ^1.3.0 version: 1.3.0(react@18.2.0) + '@t3-oss/env-nextjs': + specifier: ^0.6.0 + version: 0.6.0(typescript@5.1.6)(zod@3.21.4) '@tailwindcss/line-clamp': specifier: 0.4.4 version: 0.4.4(tailwindcss@3.3.2) @@ -162,6 +165,9 @@ importers: recoil: specifier: 0.7.7 version: 0.7.7(react-dom@18.2.0)(react@18.2.0) + zod: + specifier: ^3.21.4 + version: 3.21.4 devDependencies: '@babel/core': specifier: 7.22.5 @@ -3017,6 +3023,27 @@ packages: defer-to-connect: 1.1.3 dev: true + /@t3-oss/env-core@0.6.0(typescript@5.1.6)(zod@3.21.4): + resolution: {integrity: sha512-3FkPAba069WRZVVab/sB1m3eSGn/rZeypx5k+sWEu1d+k0OQdRDnvFS+7MtxYgqVrwaRk3b7yVnX2dgSPVmWPQ==} + peerDependencies: + typescript: '>=4.7.2' + zod: ^3.0.0 + dependencies: + typescript: 5.1.6 + zod: 3.21.4 + dev: false + + /@t3-oss/env-nextjs@0.6.0(typescript@5.1.6)(zod@3.21.4): + resolution: {integrity: sha512-SpzcGNIbUYcQw4zPPFeRJqCC1560zL7QmB0puIqOnuCsmykPkqHPX+n9CNZLXVQerboHzfvb7Kd+jAdouk72Vw==} + peerDependencies: + typescript: '>=4.7.2' + zod: ^3.0.0 + dependencies: + '@t3-oss/env-core': 0.6.0(typescript@5.1.6)(zod@3.21.4) + typescript: 5.1.6 + zod: 3.21.4 + dev: false + /@tailwindcss/line-clamp@0.4.4(tailwindcss@3.3.2): resolution: {integrity: sha512-5U6SY5z8N42VtrCrKlsTAA35gy2VSyYtHWCsg1H87NU1SXnEfekTVlrga9fzUDrrHcGi2Lb5KenUWb4lRQT5/g==} peerDependencies: From 5105b6dfc27aca80d3cc70eb68ec7f711d2c21ca Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Thu, 29 Jun 2023 22:28:26 +0900 Subject: [PATCH 2/2] =?UTF-8?q?:+1:=20=E5=9E=8B=E6=83=85=E5=A0=B1=E3=82=92?= =?UTF-8?q?=E6=8C=81=E3=81=A3=E3=81=9F=20Env=20=E3=81=AB=E5=88=87=E3=82=8A?= =?UTF-8?q?=E6=9B=BF=E3=81=88=20(#113)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/frontend/next.config.js | 3 --- apps/frontend/next.config.mjs | 14 ++++++++++ .../src/components/Utils/GoogleAnalytics.tsx | 8 +++--- apps/frontend/src/env.mjs | 27 +++++++++++++++++++ apps/frontend/src/lib/analytics/gtag.tsx | 5 ++-- apps/frontend/src/lib/constants.ts | 4 --- apps/frontend/src/lib/index.ts | 1 - 7 files changed, 47 insertions(+), 15 deletions(-) delete mode 100644 apps/frontend/next.config.js create mode 100644 apps/frontend/next.config.mjs create mode 100644 apps/frontend/src/env.mjs delete mode 100644 apps/frontend/src/lib/constants.ts diff --git a/apps/frontend/next.config.js b/apps/frontend/next.config.js deleted file mode 100644 index da1bb770..00000000 --- a/apps/frontend/next.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - reactStrictMode: true, -}; diff --git a/apps/frontend/next.config.mjs b/apps/frontend/next.config.mjs new file mode 100644 index 00000000..514d6639 --- /dev/null +++ b/apps/frontend/next.config.mjs @@ -0,0 +1,14 @@ +// Importing env files here to validate on build +import './src/env.mjs'; + +/** @type {import('next').NextConfig} */ +const config = { + reactStrictMode: true, + /** Enables hot reloading for local packages without a build step */ + transpilePackages: [], + /** We already do linting and typechecking as separate tasks in CI */ + eslint: { ignoreDuringBuilds: true }, + typescript: { ignoreBuildErrors: true }, +}; + +export default config; diff --git a/apps/frontend/src/components/Utils/GoogleAnalytics.tsx b/apps/frontend/src/components/Utils/GoogleAnalytics.tsx index d95d651c..d7c13ac1 100644 --- a/apps/frontend/src/components/Utils/GoogleAnalytics.tsx +++ b/apps/frontend/src/components/Utils/GoogleAnalytics.tsx @@ -3,14 +3,14 @@ import { usePathname, useSearchParams } from 'next/navigation'; import Script from 'next/script'; import { useEffect } from 'react'; -import { GA_TRACKING_ID, pageView } from '@/lib'; +import { pageView } from '@/lib'; +import { env } from '@/env.mjs'; const GoogleAnalytics: React.FC = () => { const pathname = usePathname(); const searchParams = useSearchParams(); useEffect(() => { - if (!GA_TRACKING_ID) return; const url = pathname + searchParams.toString(); pageView(url); }, [pathname, searchParams]); @@ -19,7 +19,7 @@ const GoogleAnalytics: React.FC = () => { <>