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

Returning custom routes in includedRoutes hook causes pages not to prerender correctly #433

Open
5 of 7 tasks
derMart opened this issue Dec 18, 2024 · 0 comments
Open
5 of 7 tasks

Comments

@derMart
Copy link

derMart commented Dec 18, 2024

Describe the bug

Consider a custom path returned via the includedRoutes hook:

includedRoutes(_paths:any[], routes:any[]) {
   // use original route records
   return routes.flatMap((route:any) => route.path + (route.path.endsWith('/') ? 'index' : '/index'));
},

If such paths are returned via the includedRoutes hook, the pages content is not prerendered but looks like this:

<body>
  <div id="app" data-server-rendered="true"><!----></div>
</body>

Have a look at the provided reproduction repo and run the npm run build command. The expected output of the pages content is:

<body>
  <div id="app" data-server-rendered="true"> TestContent </div>
<body>

This expected output can be achieved if the includedRoutes hook is removed from the vite config, but should also be present if includedRoutes are specified.

Reproduction

https://github.com/derMart/vite-ssg-includedroutes-bug

System Info

System:
  OS: Linux 6.8 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
Binaries:
  Node: 20.15.1 - ~/.nvm/versions/node/v20.15.1/bin/node
  Yarn: 1.22.19 - ~/.yarn/bin/yarn
  npm: 10.8.2 - ~/.nvm/versions/node/v20.15.1/bin/npm

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributions

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
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