diff --git a/.github/workflows/pages.yaml b/.github/workflows/pages.yaml index 8018835..98d810f 100644 --- a/.github/workflows/pages.yaml +++ b/.github/workflows/pages.yaml @@ -38,6 +38,7 @@ jobs: - name: Setup Pages uses: actions/configure-pages@v5 + # https://turbo.build/repo/docs/guides/ci-vendors/github-actions - name: Cache turbo build setup uses: actions/cache@v4 with: diff --git a/apps/frontend/.env.development b/apps/frontend/.env.development index 8cb2be9..25c9987 100644 --- a/apps/frontend/.env.development +++ b/apps/frontend/.env.development @@ -1,2 +1,3 @@ +NEXT_PUBLIC_SITE_BASE_URL=http://localhost:8001 NEXT_PUBLIC_SITE_TITLE=GabengarDev NEXT_PUBLIC_DEFAULT_LOG_LEVEL=log diff --git a/apps/frontend/.env.production b/apps/frontend/.env.production index 1491ab5..560230e 100644 --- a/apps/frontend/.env.production +++ b/apps/frontend/.env.production @@ -1,2 +1,3 @@ +NEXT_PUBLIC_SITE_BASE_URL=https://gabengar.github.io/todos NEXT_PUBLIC_SITE_TITLE=Gabengar NEXT_PUBLIC_DEFAULT_LOG_LEVEL=warn diff --git a/apps/frontend/next.config.js b/apps/frontend/next.config.js deleted file mode 100644 index 1735273..0000000 --- a/apps/frontend/next.config.js +++ /dev/null @@ -1,12 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = { - output: "export", - trailingSlash: true, - skipTrailingSlashRedirect: true, - distDir: 'dist', - experimental: { - typedRoutes: true, - }, -}; - -module.exports = nextConfig; diff --git a/apps/frontend/next.config.mjs b/apps/frontend/next.config.mjs new file mode 100644 index 0000000..6c8f3e5 --- /dev/null +++ b/apps/frontend/next.config.mjs @@ -0,0 +1,33 @@ +// @ts-check +import nextEnv from "@next/env"; + +const projectDir = process.cwd(); +nextEnv.loadEnvConfig(projectDir); + +/** + * @returns {Promise} + */ +async function createNextConfig() { + const baseURL = process.env.NEXT_PUBLIC_SITE_BASE_URL; + const basePathname = !baseURL + ? undefined + : new URL(baseURL, "https://example.com").pathname; + const basePath = + !basePathname || basePathname === "/" ? undefined : basePathname; + + /** @type {import('next').NextConfig} */ + const nextConfig = { + basePath, + output: "export", + trailingSlash: true, + skipTrailingSlashRedirect: true, + distDir: "dist", + experimental: { + typedRoutes: true, + }, + }; + + return nextConfig; +} + +export default createNextConfig; diff --git a/apps/frontend/package.json b/apps/frontend/package.json index b637984..ba4e5d5 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -13,8 +13,9 @@ "codegen": "npm run build-codegen && cd ../../packages/codegen && npm start -- ../../apps/frontend/src/codegen/generators ../../apps/frontend/src/codegen/output && cd ../../apps/frontend && prettier --log-level=warn ./src/codegen/output --write" }, "dependencies": { - "@repo/ui": "*", "@hyperjump/json-schema": "^1.8.0", + "@next/env": "^14.2.2", + "@repo/ui": "*", "ajv": "^8.12.0", "bcp-47": "^2.1.0", "clsx": "^2.1.0", diff --git a/apps/frontend/src/lib/urls/internal-url.ts b/apps/frontend/src/lib/urls/internal-url.ts new file mode 100644 index 0000000..838ac36 --- /dev/null +++ b/apps/frontend/src/lib/urls/internal-url.ts @@ -0,0 +1 @@ +export class InternalURL extends URL {} diff --git a/apps/frontend/tsconfig.json b/apps/frontend/tsconfig.json index dbf029d..a5b8c1b 100644 --- a/apps/frontend/tsconfig.json +++ b/apps/frontend/tsconfig.json @@ -75,7 +75,8 @@ "next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", - "**/*.tsx" + "**/*.tsx", + "dist/types/**/*.ts" ], "exclude": [ "node_modules", diff --git a/package-lock.json b/package-lock.json index 1617dd8..5e448eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -101,6 +101,7 @@ "version": "0.39.0", "dependencies": { "@hyperjump/json-schema": "^1.8.0", + "@next/env": "^14.2.2", "@repo/ui": "*", "ajv": "^8.12.0", "bcp-47": "^2.1.0", @@ -128,6 +129,12 @@ "typescript": "^5.4.5" } }, + "apps/frontend/node_modules/@next/env": { + "version": "15.0.3", + "resolved": "https://registry.npmjs.org/@next/env/-/env-15.0.3.tgz", + "integrity": "sha512-t9Xy32pjNOvVn2AS+Utt6VmyrshbpfUMhIjFO60gI58deSo/KgLOp31XZ4O+kY/Is8WAGYwA5gR7kOb1eORDBA==", + "license": "MIT" + }, "apps/frontend/node_modules/prettier": { "version": "3.2.5", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", @@ -17759,6 +17766,7 @@ "version": "file:apps/frontend", "requires": { "@hyperjump/json-schema": "^1.8.0", + "@next/env": "^14.2.2", "@repo/ui": "*", "@types/negotiator": "^0.6.3", "@types/node": "^20.12.7", @@ -17784,6 +17792,10 @@ "typescript": "^5.4.5" }, "dependencies": { + "@next/env": { + "version": "https://registry.npmjs.org/@next/env/-/env-15.0.3.tgz", + "integrity": "sha512-t9Xy32pjNOvVn2AS+Utt6VmyrshbpfUMhIjFO60gI58deSo/KgLOp31XZ4O+kY/Is8WAGYwA5gR7kOb1eORDBA==" + }, "prettier": { "version": "3.2.5", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz",