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

Run SPA in sub path #440

Open
khanhicetea opened this issue Dec 15, 2024 · 0 comments
Open

Run SPA in sub path #440

khanhicetea opened this issue Dec 15, 2024 · 0 comments

Comments

@khanhicetea
Copy link

Hi I wondering that , is it possible to run SPA in the subpath like /app :

  • /app => SPA
  • /api => API
  • /* : public assets or SSR

I tried this config but some weird error in dev mode ( the index root is using spa index.html ) and build mode ( not found './routes' in spa building )

import { defineConfig } from '@tanstack/start/config'
import tsConfigPaths from 'vite-tsconfig-paths'
import reactRefresh from '@vitejs/plugin-react'
import { TanStackRouterVite } from '@tanstack/router-plugin/vite'

const appConfig = defineConfig({
  tsr: {
    appDirectory: 'pages',
  },
  vite: {
    plugins: [
      tsConfigPaths({ projects: ['./tsconfig.json'] }),
    ],
  },
})

appConfig.addRouter({
  name: 'spa-app',
  type: 'spa',
  base: '/app',
  handler: './index.html',
  root: "spa",
  target: "browser",
  plugins: () => [
    tsConfigPaths(),
    TanStackRouterVite({
      routesDirectory: './routes',
      generatedRouteTree: './routeTree.gen.ts',
      autoCodeSplitting: true,
    }),
    reactRefresh()
  ],
});

export default appConfig;

Below is my file tree structure:

image
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

No branches or pull requests

1 participant