Skip to content

Commit

Permalink
feat: support subpath pages build
Browse files Browse the repository at this point in the history
  • Loading branch information
GabenGar committed Nov 22, 2024
1 parent bdd07f5 commit 9c2242f
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/.env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
NEXT_PUBLIC_SITE_BASE_URL=http://localhost:8001
NEXT_PUBLIC_SITE_TITLE=GabengarDev
NEXT_PUBLIC_DEFAULT_LOG_LEVEL=log
1 change: 1 addition & 0 deletions apps/frontend/.env.production
Original file line number Diff line number Diff line change
@@ -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
12 changes: 0 additions & 12 deletions apps/frontend/next.config.js

This file was deleted.

33 changes: 33 additions & 0 deletions apps/frontend/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// @ts-check
import nextEnv from "@next/env";

const projectDir = process.cwd();
nextEnv.loadEnvConfig(projectDir);

/**
* @returns {Promise<import('next').NextConfig>}
*/
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;
3 changes: 2 additions & 1 deletion apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/lib/urls/internal-url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class InternalURL extends URL {}
3 changes: 2 additions & 1 deletion apps/frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"next-env.d.ts",
".next/types/**/*.ts",
"**/*.ts",
"**/*.tsx"
"**/*.tsx",
"dist/types/**/*.ts"
],
"exclude": [
"node_modules",
Expand Down
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c2242f

Please sign in to comment.