Skip to content

Comments

♻️ refactor: migrate frontend from Next.js App Router to Vite SPA#12404

Open
Innei wants to merge 54 commits intocanaryfrom
refactor/vite-4
Open

♻️ refactor: migrate frontend from Next.js App Router to Vite SPA#12404
Innei wants to merge 54 commits intocanaryfrom
refactor/vite-4

Conversation

@Innei
Copy link
Member

@Innei Innei commented Feb 20, 2026

Summary

Migrate the LobeChat frontend from Next.js App Router client-side rendering to a standalone Vite SPA, while keeping Next.js solely for server-side API routes, auth, and SEO pages. This decouples the heavy client bundle from Next.js, enables faster HMR via Vite, and unifies the web + Electron desktop renderer under a shared Vite config.

Phases

Phase 1 — Environment Variable Cleanup

  • Migrate @t3-oss/env-nextjs@t3-oss/env-core
  • Replace Next.js-specific analytics with vanilla JS

Phase 2 — Vite Project Setup

  • Add root vite.config.ts with React plugin, path aliases, and import.meta.glob locale loading
  • Register dev:next task in turbo.json for parallel Vite + Next dev startup
  • Set Vite base: '/spa/' for production builds; auto-generate spaHtmlTemplates from build output

Phase 3 — First-Party Package Decoupling

  • Remove Next.js dependencies from @lobechat/* packages
  • Replace next-mdx-remote/rsc with react-markdown

Phase 4 — Route & Navigation Migration

  • 4a: Auth pages switch from abstraction helpers to direct next/navigation + next/link
  • 4b: All SPA pages migrate from Next.js router abstractions to react-router-dom / vanilla React
  • Rename (spa) route group → spa segment; rewrite SPA routes via Next.js middleware
  • Add SPA catch-all route handler with Vite dev proxy

Phase 5 — SPA Runtime

  • Create SPAGlobalProvider (theme, i18n, auth context, router)
  • Add locale detection script in index.html for SPA dev mode
  • Add [locale] segment with force-static and SEO meta generation

Phase 6 — Electron Desktop Integration

  • Unify isDesktop__ELECTRON__ compile-time constant
  • Extract shared renderer Vite config (sharedRendererConfig)
  • Add Vite renderer entry to electron-vite config; use ELECTRON_RENDERER_URL instead of hardcoded port
  • Add .desktop suffix files for eager i18n loading
  • Update electron-builder files config for Vite renderer output
  • Remove all legacy electron modifier scripts

Misc

  • Remove @ast-grep/napi dependency
  • Remove old Next.js route segment files and serwist PWA
  • Update build scripts and Dockerfile for SPA integration
  • Clean up CI workflows

File Changes

  • 717 files changed, 66720 insertions, 10360 deletions
  • Key areas: src/, apps/desktop/, packages/, vite.config.ts, turbo.json, next.config.ts, Dockerfile

Type of Change

  • Breaking change
  • New feature
  • Refactoring

Testing

  • Desktop Electron build verified with shared Vite renderer config
  • Vite dev server + Next.js API proxy tested locally
  • i18n locale loading via import.meta.glob validated

Checklist

  • SPA routes render correctly under /spa/ prefix
  • Next.js API routes and auth still work
  • Electron desktop renderer uses shared Vite config
  • Production build generates correct spaHtmlTemplates
  • Locale detection works in SPA dev mode

@vercel
Copy link

vercel bot commented Feb 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobehub Error Error Feb 22, 2026 5:44pm

Request Review

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 20, 2026

Reviewer's Guide

Migrates the LobeChat frontend from Next.js App Router to a Vite + React Router SPA while keeping the Next.js backend, by introducing a SPA entry and global provider, a Next.js catch-all route that serves Vite-built HTML with runtime config injection, refactoring the Next-specific abstraction layer and third‑party integrations to framework-agnostic adapters, updating env handling, and wiring new build/dev/Docker flows for dual desktop/mobile bundles.

Sequence diagram for SPA HTML request via Next.js catch-all

sequenceDiagram
  participant U as Browser
  participant M as Middleware_define_config
  participant R as SPACatchAllRoute
  participant C as getServerGlobalConfig
  participant T as spaHtmlTemplates_or_ViteDev

  U->>M: GET /chat
  M->>M: Check path
  M->>M: isNextjsRoute = nextjsOnlyRoutes.some
  alt isNextjsRoute true
    M-->>U: Rewrite to Next.js auth route
  else SPA route
    M->>R: NextResponse.next()\npass to (spa)/[[...path]]
    R->>R: Detect isMobile from UA
    R->>R: Resolve locale\nfrom LOBE_LOCALE_COOKIE or headers
    R->>C: getServerGlobalConfig()
    C-->>R: GlobalServerConfig
    R->>R: getServerFeatureFlagsValue
    R->>R: buildAnalyticsConfig
    R->>R: buildThemeConfig
    R->>R: buildClientEnv
    R->>T: getTemplate(isMobile)
    alt NODE_ENV=development
      T->>T: fetch VITE_DEV_ORIGIN index.html
      T->>T: rewriteViteAssetUrls
    else production
      T->>T: read public/spa/[desktop|mobile]/index.html
    end
    T-->>R: HTML template
    R->>R: serializeForHtml(SPAServerConfig)
    R->>R: Inject window.__SERVER_CONFIG__\nReplace LOCALE, DIR placeholders
    R-->>U: HTML response
    U->>U: Load JS bundle\nBootstrap React Router SPA
  end
Loading

Class diagram for SPA server config and global provider

classDiagram
  class SPAServerConfig {
    +AnalyticsConfig analyticsConfig
    +SPAClientEnv clientEnv
    +GlobalServerConfig config
    +Partial~IFeatureFlags~ featureFlags
    +boolean isMobile
    +string locale
    +SPAThemeConfig theme
  }

  class AnalyticsConfig {
    +GoogleConfig google
    +PlausibleConfig plausible
    +UmamiConfig umami
    +ClarityConfig clarity
    +PosthogConfig posthog
    +ReactScanConfig reactScan
    +VercelConfig vercel
    +DesktopAnalyticsConfig desktop
  }

  class SPAClientEnv {
    +string marketBaseUrl
    +string pyodideIndexUrl
    +string pyodidePipIndexUrl
    +string s3FilePath
  }

  class SPAThemeConfig {
    +boolean cdnUseGlobal
    +string customFontFamily
    +string customFontURL
  }

  class Window {
    +SPAServerConfig __SERVER_CONFIG__
  }

  class SPAGlobalProvider {
    +render(children)
  }

  class ServerConfigStoreProvider {
    +featureFlags
    +isMobile
    +serverConfig
  }

  class BrowserRouter {
  }

  class Routes {
  }

  class desktopRoutes {
  }

  class mobileRoutes {
  }

  Window --> SPAServerConfig : holds
  SPAServerConfig --> AnalyticsConfig : has
  SPAServerConfig --> SPAClientEnv : has
  SPAServerConfig --> SPAThemeConfig : has

  SPAGlobalProvider --> SPAServerConfig : reads
  SPAGlobalProvider --> ServerConfigStoreProvider : composes
  SPAGlobalProvider --> BrowserRouter : wraps
  BrowserRouter --> Routes : renders
  Routes --> desktopRoutes : uses
  Routes --> mobileRoutes : uses
Loading

File-Level Changes

Change Details Files
Replace Next.js navigation and component adapters with SPA-compatible react-router-dom and plain React implementations while preserving the existing public API.
  • Reimplemented navigation helpers (useRouter, usePathname, useParams, useSearchParams, redirect, notFound, useServerInsertedHTML) to use react-router-dom and custom error types, keeping the old API shape for callers.
  • Replaced the next/dynamic-based dynamic() wrapper with a React.lazy + Suspense implementation that accepts the same loader/options contract.
  • Replaced the next/image-based Image wrapper with a forwardRef adapter that supports StaticImageData-like objects and the fill layout behavior.
  • Replaced the next/link-based Link wrapper with a react-router-dom Link adapter that renders external URLs as plain elements.
  • Centralized these adapters behind src/libs/next/index.ts so existing imports continue to work in SPA mode.
src/libs/next/navigation.ts
src/libs/next/dynamic.tsx
src/libs/next/Image.tsx
src/libs/next/Link.tsx
src/libs/next/index.ts
Introduce a Vite-powered SPA runtime with separate desktop/mobile bundles and a new SPAGlobalProvider that reads runtime config from window.SERVER_CONFIG.
  • Added Vite configuration with React plugin, tsconfig path resolution, dev proxy to the Next.js backend, and MOBILE-driven dual build output to dist/desktop and dist/mobile.
  • Added index.html as the SPA HTML template with placeholders for locale, direction, SEO, analytics, and a script slot where window.SERVER_CONFIG is injected.
  • Created desktop and mobile SPA entrypoints that render react-router-dom Routes using existing router configs and wrap them with the new SPAGlobalProvider.
  • Implemented SPAGlobalProvider as a client-only provider stack mirroring GlobalProvider but hydrated from window.SERVER_CONFIG, including server config store, theme, auth, analytics wrapper, and business hooks.
  • Defined SPAServerConfig, theme, analytics, and client env types plus global.d.ts declarations for window.SERVER_CONFIG and MOBILE.
vite.config.ts
index.html
src/entry.desktop.tsx
src/entry.mobile.tsx
src/layout/SPAGlobalProvider/index.tsx
src/types/spaServerConfig.ts
src/types/global.d.ts
Serve the SPA HTML from Next.js via a catch-all route that loads Vite-built templates (or proxies Vite dev server), injects runtime server config, and cooperates with middleware/auth routing rules.
  • Added a (spa)/[[...path]] route handler that detects mobile via user agent, chooses desktop/mobile templates, builds SPAServerConfig from existing env/config modules, and safely serializes it into window.SERVER_CONFIG along with locale/dir placeholders.
  • Implemented spaHtmlTemplates utilities to read pre-built SPA HTML from public/spa/desktop and public/spa/mobile at runtime.
  • Implemented a serializeForHtml helper to safely embed JSON into inline scripts by escaping special sequences.
  • Added dev-mode template logic using linkedom to rewrite script/link URLs to the Vite dev origin and injected a Worker patch to support module workers across origins.
  • Updated next middleware proxy define-config to distinguish Next.js-only auth routes from SPA routes, route SPA traffic through the catch-all without locale rewrites, and exempt SPA paths from auth protection while continuing to protect backend and auth endpoints.
src/app/(spa)/[[...path]]/route.ts
src/app/(spa)/[[...path]]/spaHtmlTemplates.ts
src/server/utils/serializeForHtml.ts
catch-all.eg.ts
src/libs/next/proxy/define-config.ts
Adjust auth-related pages and middleware so that auth flows remain on Next.js App Router while SPA routes become public shells with client-side auth.
  • Changed auth pages and hooks that previously depended on the libs/next wrappers to import next/link or next/navigation directly where needed, to remain compatible with the Next.js runtime.
  • Defined a set of nextjsOnlyRoutes in the middleware router config (signin, signup, auth-error, reset-password, verify-email, oauth, market-auth-callback, discover, welcome) that are explicitly not sent to the SPA catch-all.
  • Modified middleware logic so SPA routes (non-auth, non-backend endpoints) bypass auth enforcement, relying instead on client-side auth within the SPA.
  • Preserved (auth) segment behavior by not moving those routes into the SPA and leaving their Next.js-specific behavior intact.
src/app/[variants]/(auth)/auth-error/page.tsx
src/app/[variants]/(auth)/oauth/callback/error/page.tsx
src/app/[variants]/(auth)/oauth/callback/success/page.tsx
src/app/[variants]/(auth)/oauth/consent/[uid]/page.tsx
src/app/[variants]/(auth)/reset-password/page.tsx
src/app/[variants]/(auth)/signin/useSignIn.ts
src/app/[variants]/(auth)/signup/[[...signup]]/BetterAuthSignUpForm.tsx
src/app/[variants]/(auth)/signup/[[...signup]]/useSignUp.tsx
src/app/[variants]/(auth)/verify-email/page.tsx
src/libs/next/proxy/define-config.ts
Refactor environment variable handling to be framework-agnostic, fix inconsistencies, and introduce SPA-specific client env wiring.
  • Switched env schema factories from @t3-oss/env-nextjs to @t3-oss/env-core across multiple env modules and configured clientPrefix: 'NEXT_PUBLIC_' where needed.
  • Fixed the Pyodide env inconsistency by reading NEXT_PUBLIC_PYODIDE_INDEX_URL and NEXT_PUBLIC_PYODIDE_PIP_INDEX_URL from pythonEnv instead of raw process.env, and corrected the variable name used for PIP index.
  • Introduced SPAClientEnv fields (marketBaseUrl, pyodide URLs, S3 file path) and wired them into the SPAServerConfig builder using appEnv, pythonEnv, and fileEnv.
  • Changed MARKET_BASE_URL usage on the server side from the NEXT_PUBLIC_ variant to a server-only MARKET_BASE_URL in OIDC routes and market/discover services.
  • Added isDesktop constants in various packages that prefer import.meta.env.VITE_IS_DESKTOP_APP when available and fall back to the legacy NEXT_PUBLIC_IS_DESKTOP_APP environment variable for backward compatibility.
src/envs/app.ts
src/envs/auth.ts
src/envs/file.ts
src/envs/python.ts
src/envs/analytics.ts
src/envs/email.ts
src/envs/knowledge.ts
src/envs/langfuse.ts
src/envs/llm.ts
src/envs/tools.ts
src/services/python.ts
src/types/spaServerConfig.ts
src/server/services/market/index.ts
src/server/routers/lambda/market/agent.ts
src/server/routers/lambda/market/agentGroup.ts
src/server/services/discover/index.ts
src/app/(backend)/market/oidc/[[...segments]]/route.ts
packages/builtin-tool-group-management/src/const.ts
packages/builtin-tool-gtd/src/const.ts
packages/const/src/version.ts
Replace several Next.js-specific third-party integrations (analytics, MDX, PWA) with framework-neutral or SPA-compatible implementations.
  • Replaced Google Analytics via @next/third-parties/google with a client-side component that injects the gtag script using useEffect and analyticsEnv.
  • Reimplemented ReactScan monitoring from react-scan/monitoring/next as a client component that injects the auto.global script with appropriate dataset attributes.
  • Replaced the Desktop analytics Script-based integration using next/script with a useEffect-based dynamic script injection that reads desktop analytics env vars.
  • Swapped MDX rendering from next-mdx-remote/rsc to react-markdown, mapping components for links, images, and code blocks into Markdown’s components prop.
  • Removed the Serwist Next PWA wrapper integration from the Next.js config so the SPA can later adopt a Vite PWA plugin instead.
src/components/Analytics/Desktop.tsx
src/components/Analytics/Google.tsx
src/components/Analytics/ReactScan.tsx
src/components/mdx/index.tsx
src/libs/next/config/define-config.ts
package.json
Wire the new SPA build into scripts, Docker, and remove obsolete Next.js route shells in favor of SPA routing.
  • Updated package.json scripts to add build:spa, build:spa:copy, dev:spa, dev:spa:mobile, dev:next, and changed dev to point at the Vite dev server; build:docker now runs SPA build and copies dist into public/spa before the Next.js build.
  • Added Vite-related and spa-supporting dependencies (react-markdown, @vitejs/plugin-react, linkedom, tsconfig-paths) and updated dependency lists accordingly.
  • Updated the Dockerfile to copy SPA assets from the builder stage into /app/public/spa alongside the Next.js standalone output and desktop export.
  • Removed legacy Next.js [variants] route segment shells and loading/error/not-found pages that previously served as the frontend entrypoint, as the SPA now owns frontend routing.
  • Adjusted miscellaneous components to avoid depending on SPA Link/Image wrappers where plain or is more appropriate for external URLs and icons, especially in built-in tooling UIs.
package.json
Dockerfile
src/app/[variants]/error.tsx
src/app/[variants]/loaders/routeParams.ts
src/app/[variants]/loading.tsx
src/app/[variants]/not-found.tsx
src/app/[variants]/page.tsx
src/app/loading.tsx
packages/builtin-tool-agent-builder/src/client/Intervention/InstallPlugin.tsx
packages/builtin-tool-web-browsing/src/client/Portal/PageContent/index.tsx
packages/builtin-tool-web-browsing/src/client/Render/PageContent/Loading.tsx
packages/builtin-tool-web-browsing/src/client/Render/PageContent/Result.tsx
packages/builtin-tool-web-browsing/src/client/Render/Search/SearchResult/SearchResultItem.tsx
Provide Vite-specific utilities for i18n and antd locale loading that avoid Next.js/CJS-specific patterns.
  • Added a Vite-oriented i18n namespace loader that uses import.meta.glob over JSON and TS locale modules, with a fallback helper that reports and recovers from missing locales.
  • Added a Vite-specific antd locale loader that reads ESM locale files from antd/es/locale via import.meta.glob and normalizes locale codes, replacing dynamic Next-style imports.
  • Ensured these Vite utilities can be aliased in the SPA build to provide the correct runtime behavior without affecting the Next.js backend.
src/utils/i18n/loadI18nNamespaceModule.vite.ts
src/utils/locale.vite.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

}

const response = await sdk.feedback.submitFeedback({
const response = await lambdaClient.market.submitFeedback.mutate({
Innei added 18 commits February 22, 2026 21:26
- Clarified the handling of Worker cross-origin issues in dev mode, emphasizing the need for `workerPatch` to wrap cross-origin URLs as blob URLs.
- Enhanced the explanation of the dev mode's resource URL rewriting process for better understanding.

Signed-off-by: Innei <tukon479@gmail.com>
- Fix Pyodide env var mismatch (NEXT_PUBLIC_PYPI_INDEX_URL → pythonEnv.NEXT_PUBLIC_PYODIDE_PIP_INDEX_URL)
- Consolidate python.ts to use pythonEnv instead of direct process.env
- Remove NEXT_PUBLIC_ prefix from server-side MARKET_BASE_URL (5 files)
- Add vite.config.ts with dual build (desktop/mobile via MOBILE env)
- Add index.html SPA template with __SERVER_CONFIG__ placeholder
- Add entry.desktop.tsx and entry.mobile.tsx SPA entry points
- Add dev:spa, dev:spa:mobile, build:spa, build:spa:copy scripts
- Install @vitejs/plugin-react and linkedom
- Replace next/link with <a> in builtin-tool-web-browsing (4 files, external links)
- Replace next/image with <img> in builtin-tool-agent-builder/InstallPlugin.tsx
- Add Vite import.meta.env compat for isDesktop in const/version.ts, builtin-tool-gtd, builtin-tool-group-management
- 9 auth files: @/libs/next/navigation → next/navigation
- 5 auth files: @/libs/next/Link → next/link
- Auth pages remain in Next.js App Router, need direct Next.js imports
- navigation.ts: useRouter/usePathname/useSearchParams/useParams → react-router-dom
- navigation.ts: redirect/notFound → custom error throws
- navigation.ts: useServerInsertedHTML → no-op for SPA
- Link.tsx: next/link → react-router-dom Link adapter (href→to, external→<a>)
- Image.tsx: next/image → <img> wrapper with fill/style support
- dynamic.tsx: next/dynamic → React.lazy + Suspense wrapper
- Create SPAServerConfig type (analyticsConfig, clientEnv, theme, featureFlags, locale)
- Add window.__SERVER_CONFIG__ and __MOBILE__ to global.d.ts
- Create SPAGlobalProvider (client-only Provider tree mirroring GlobalProvider)
- Includes AuthProvider for user session support
- Update entry.desktop.tsx and entry.mobile.tsx to wrap with SPAGlobalProvider
- Create (spa)/[[...path]]/route.ts for serving SPA HTML
- Dev mode: proxy Vite dev server, rewrite asset URLs, inject Worker patch
- Prod mode: read pre-built HTML templates
- Build SPAServerConfig with analytics, theme, clientEnv, featureFlags
- Update middleware to pass SPA routes through to catch-all
SPA pages are all public (no sensitive data in HTML).
Auth is handled client-side by SPAGlobalProvider's AuthProvider.
Only Next.js auth routes and API endpoints go through session checks.
- Google.tsx: replace @next/third-parties/google with direct gtag script
- ReactScan.tsx: replace react-scan/monitoring/next with generic script
- Desktop.tsx: replace next/script with native script injection
Replace framework-specific env validation with framework-agnostic version.
Add clientPrefix where client schemas exist.
Use client-side react-markdown for MDX rendering instead of
Next.js RSC-dependent next-mdx-remote.
- build:docker now includes SPA build + copy steps
- dev defaults to Vite SPA, dev:next for Next.js backend
- Dockerfile copies public/spa/ assets for production
- Add public/spa/ to .gitignore (build artifact)
- Delete [variants] page.tsx, error.tsx, not-found.tsx, loading.tsx
- Delete root loading.tsx and empty [[...path]] directory
- Delete unused loaders directory
- Remove @serwist/next PWA wrapper from Next.js config
…ded port 3015

Replace hardcoded http://localhost:3015 with process.env.ELECTRON_RENDERER_URL
injected by electron-vite dev server. Clean up stale Next.js references.
HTML entry ../../src/entry.desktop.tsx resolves to /src/entry.desktop.tsx
in URL space, which Vite cannot find within apps/desktop/ root. Add a
local shim that imports across root via module resolver instead.
…nfig

Deduplicate plugins (nodeModuleStub, platformResolve, tsconfigPaths) and
define (__MOBILE__, __ELECTRON__, process.env) between root vite.config.ts
and electron.vite.config.ts renderer section.
…nfig

sharedRendererPlugins now includes react, codeInspectorPlugin alongside
nodeModuleStub, platformResolve, tsconfigPaths. Add sharedOptimizeDeps
for pre-bundling list. Both root and electron configs consume shared only.
…esolution

import.meta.glob with absolute paths (e.g. /node_modules/antd/...) resolved
within apps/desktop/ instead of monorepo root. Change renderer root to ROOT_DIR,
add electronDesktopHtmlPlugin middleware to rewrite / to /apps/desktop/index.html,
and remove the now-unnecessary renderer-entry.ts shim.
Signed-off-by: Innei <tukon479@gmail.com>
Signed-off-by: Innei <tukon479@gmail.com>
@Innei Innei marked this pull request as ready for review February 22, 2026 13:26
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @Innei, your pull request is larger than the review limit of 150000 diff characters

Signed-off-by: Innei <tukon479@gmail.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a40b10bbd2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"build:vercel": "tsx scripts/prebuild.mts && npm run lint:ts && npm run lint:style && npm run type-check:tsc && npm run lint:circular && cross-env NODE_OPTIONS=--max-old-space-size=6144 next build --webpack && npm run postbuild",
"build": "bun run build:spa && bun run build:spa:copy && bun run build:next",
"build:analyze": "NODE_OPTIONS=--max-old-space-size=81920 ANALYZE=true next build",
"build:docker": "npm run prebuild && bun run build:spa && bun run build:spa:copy && NODE_OPTIONS=--max-old-space-size=8192 DOCKER=true next build && npm run build-sitemap",

Choose a reason for hiding this comment

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

P1 Badge Restore missing prebuild script for build:docker

The build:docker command now invokes npm run prebuild, but this commit removed the prebuild entry from scripts. In a clean checkout, npm run build:docker exits immediately with Missing script: "prebuild", so Docker image builds are blocked before any SPA/Next build steps run.

Useful? React with 👍 / 👎.

package.json Outdated
"build:analyze": "NODE_OPTIONS=--max-old-space-size=81920 ANALYZE=true next build",
"build:docker": "npm run prebuild && bun run build:spa && bun run build:spa:copy && NODE_OPTIONS=--max-old-space-size=8192 DOCKER=true next build && npm run build-sitemap",
"build:next": "cross-env NODE_OPTIONS=--max-old-space-size=8192 next build",
"build:spa": "rm -rf public/spa && NODE_OPTIONS=--max-old-space-size=8192 vite build && tsx scripts/generateSpaTemplates.mts",

Choose a reason for hiding this comment

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

P1 Badge Build mobile SPA assets before template generation

This build:spa script runs a single default vite build and then generates templates that read dist/mobile/index.html (and later copies dist/mobile/assets). Because no mobile build is triggered here, clean builds fail with missing dist/mobile artifacts (or silently use stale mobile outputs left from prior runs), which makes the SPA build pipeline unreliable.

Useful? React with 👍 / 👎.

- Changed the path in .gitignore and related files from [locale] to [variants] for SPA templates.
- Updated index.html to set body height to 100%.
- Cleaned up package.json by removing unused dependencies and reorganizing devDependencies.
- Refactored RendererUrlManager to use a constant for SPA entry HTML path.
- Removed obsolete route.ts file from the SPA structure.
- Adjusted proxy configuration to reflect the new SPA path structure.

Signed-off-by: Innei <tukon479@gmail.com>
- Modified the build script in package.json to add the mobile SPA build step.
- Ensured the build process accommodates both desktop and mobile SPA versions.

Signed-off-by: Innei <tukon479@gmail.com>
- Modified the build script in package.json to ensure the SPA copy step runs after the build.
- Updated file encoding in generateSpaTemplates.mts from 'utf-8' to 'utf8' for consistency.

Signed-off-by: Innei <tukon479@gmail.com>
- Fixed the Blob import syntax in route.ts to ensure proper module loading.
- Updated the global server configuration type in global.d.ts for improved type safety.

Signed-off-by: Innei <tukon479@gmail.com>
- Modified the mock implementation in RendererUrlManager.test.ts to check for the updated file path '/mock/export/out/apps/desktop/index.html'.
- Adjusted the expected resolved path in the test to match the new structure.

Signed-off-by: Innei <tukon479@gmail.com>
- Deleted the catch-all example file `catch-all.eg.ts` to streamline the codebase.
- Updated import paths in `ClientResponsiveLayout.tsx` and `ClientResponsiveContent/index.tsx` to use the new dynamic import location.
- Added type declarations for HTML templates in `spaHtmlTemplates.d.ts`.
- Adjusted `tsconfig.json` to include the updated file structure.
- Enhanced type definitions in `global.d.ts` and fixed locale loading in `locale.vite.ts`.

Signed-off-by: Innei <tukon479@gmail.com>
Signed-off-by: Innei <tukon479@gmail.com>
- Deleted the `build:vercel` script from package.json to streamline the build process.
- Ensured the remaining build scripts are organized and relevant.

Signed-off-by: Innei <tukon479@gmail.com>
- Changed the build input path in vite.config.ts to conditionally use 'index.mobile.html' for mobile builds, enhancing support for mobile SPA versions.

Signed-off-by: Innei <tukon479@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant