You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by WaldemarEnns October 19, 2024
Description
Hello there! My setup is quite easy:
Nuxt 3
Strapi 4 (headless CMS)
nuxt-i18n v8
ℹ See details and code below.
I use SSG for generating my /posts route, which contains a NuxtLink / NuxtLinkLocale to redirect to the /posts/[slug].vue page, where the slug is a value that I fetch using useAsyncData fom my CMS. The slug is a translated string.
My issue: Whenever I execute npm run generate, my /posts page is being crawled by the nitro crawler (due to SSG -> see https://nuxt.com/docs/getting-started/prerendering#crawl-based-pre-rendering) and then the output is basically all possible combinations of /{locale}/posts/{slug} instead of only using the correct slugs for the correct current locale.
As you will notice: I am adding custom prerender routes to my nuxt.config.ts in a prerender hook to allow my dynamic and translated blog-post pages to be prerendered as well.
What I noticed
I noticed that due to how nuxt-i18n works, the nitro-crawler crawls the /posts page and notices the NuxtLink component. It then renders the /posts page for each available locale but does not effectively wait for useAsyncData to retrieve the correct posts slug to use it for each individual locale - so I end up with all slugs being passed around to all locales, resulting in all possible combinations being prerendered (see output below).
Commenting out that NuxtLink results in my /posts pages being prerendered correctly but of course, my /posts/[slug].vue pages are not prerendered at all (I am wondering why, since I have added those routes within my nitro prerender hook?).
Executingnpm run generateresolves in the following output:
> generate
> nuxt generate
Nuxt 3.13.0 with Nitro 2.9.7 9:43:43 AM
ℹ Using Nitro server preset: static 9:43:43 AM
WARN Locale en-US uses deprecated iso property, this will be replaced with language in v9 9:43:44 AM
WARN Locale de-DE uses deprecated iso property, this will be replaced with language in v9 9:43:44 AM
WARN Locale es-ES uses deprecated iso property, this will be replaced with language in v9 9:43:44 AM
ℹ Strapi Admin URL: http://localhost:1337/admin 9:43:44 AM
ℹ Building client... 9:43:46 AM
ℹ vite v5.4.2 building for production... 9:43:46 AM
transforming (30) node_modules/@nuxtjs/strapi/dist/runtime/plugins/strapi.mjs
🌼 daisyUI 4.12.10
├─ ✔︎ 1 theme added https://daisyui.com/docs/themes
╰─ ★ Star daisyUI on GitHub https://github.com/saadeghi/daisyui
🌼 daisyUI 4.12.10
├─ ✔︎ 1 theme added https://daisyui.com/docs/themes
╰─ ★ Star daisyUI on GitHub https://github.com/saadeghi/daisyui
ℹ ✓ 285 modules transformed. 9:43:48 AM
ℹ .nuxt/dist/client/manifest.json 4.05 kB │ gzip: 0.73 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/me-nice.DvpNxJFD.webp 50.75 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/DG4bOlEm.js 0.05 kB │ gzip: 0.07 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/BAuNtLH8.js 0.39 kB │ gzip: 0.27 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/DMc_d7rI.js 1.11 kB │ gzip: 0.70 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/gVPKDidy.js 1.19 kB │ gzip: 0.62 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/DQzosCdq.js 1.94 kB │ gzip: 1.04 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/BpHdCoCs.js 3.14 kB │ gzip: 1.29 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/B0b5cSv1.js 4.62 kB │ gzip: 1.79 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/kVb0BvLv.js 5.47 kB │ gzip: 2.25 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/DYO3Utho.js 5.57 kB │ gzip: 2.16 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/BepMiEE1.js 5.97 kB │ gzip: 1.79 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/BK7By3gy.js 6.82 kB │ gzip: 2.54 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/iFC89kKu.js 7.33 kB │ gzip: 2.78 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/BlgLqlAW.js 7.38 kB │ gzip: 2.91 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/B80KJxi6.js 18.57 kB │ gzip: 6.22 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/BQOVOFqx.js 64.83 kB │ gzip: 22.46 kB 9:43:48 AM
ℹ .nuxt/dist/client/_nuxt/DdQLhhar.js 1,802.32 kB │ gzip: 645.66 kB 9:43:48 AM
WARN 9:43:48 AM
(!) Some chunks are larger than 500 kB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
ℹ ✓ built in 2.69s 9:43:48 AM
✔ Client built in 2700ms 9:43:48 AM
ℹ Building server... 9:43:48 AM
ℹ vite v5.4.2 building SSR bundle for production... 9:43:48 AM
🌼 daisyUI 4.12.10
├─ ✔︎ 1 theme added https://daisyui.com/docs/themes
╰─ ❤︎ Support daisyUI project: https://opencollective.com/daisyui
ℹ ✓ 156 modules transformed. 9:43:49 AM
ℹ .nuxt/dist/server/_nuxt/entry-styles.D1dDi6Ct.mjs 0.15 kB 9:43:50 AM
ℹ .nuxt/dist/server/styles.mjs 0.18 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/i18n.config-DFpEEJ-m.js 0.14 kB │ map: 0.25 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/imprint-BMTPl06g.js 1.69 kB │ map: 0.12 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/index-C2ZOk5Bz.js 4.90 kB │ map: 5.45 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/asyncData-DZqpHzLd.js 5.70 kB │ map: 13.80 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/_slug_-YEQXaDNx.js 7.33 kB │ map: 6.89 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/post-DCziuADD.js 8.74 kB │ map: 1.64 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/index-CHlx4C00.js 8.95 kB │ map: 0.34 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/en-US-BjnJqz2B.js 9.54 kB │ map: 0.21 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/entry-styles-2.mjs-DCojknPs.js 9.76 kB │ map: 0.11 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/nuxt-link-DlgbMrns.js 10.10 kB │ map: 21.33 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/es-ES-i3nj40x5.js 10.10 kB │ map: 0.21 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/de-DE-mFyRyKcu.js 10.11 kB │ map: 0.21 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/Footer-Dj7BXt52.js 11.00 kB │ map: 12.78 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/privacy-policy-Bjunibn-.js 17.75 kB │ map: 0.13 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/default-ByI_OZNR.js 21.48 kB │ map: 14.85 kB 9:43:50 AM
ℹ .nuxt/dist/server/_nuxt/entry-styles-1.mjs-A6rTqk02.js 63.37 kB │ map: 0.11 kB 9:43:50 AM
ℹ .nuxt/dist/server/server.mjs 300.96 kB │ map: 681.44 kB 9:43:50 AM
ℹ ✓ built in 1.37s 9:43:50 AM
✔ Server built in 1382ms 9:43:50 AM
ℹ Initializing prerenderer nitro 9:43:50 AM
[9:43:51 AM] WARN Export "useNitroApp" of module "node_modules/nitropack/dist/runtime/app.mjs" was reexported through module "node_modules/nitropack/dist/runtime/index.mjs" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
Either change the import in "node_modules/@nuxtjs/sitemap/dist/runtime/nitro/routes/sitemap_index.xml.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.
ℹ Prerendering 8 initial routes with crawler nitro 9:43:51 AM
├─ /robots.txt (12ms) nitro 9:43:51 AM
├─ /__sitemap__/style.xsl (5ms) nitro 9:43:51 AM
├─ /200.html (66ms) nitro 9:43:51 AM
├─ /404.html (66ms) nitro 9:43:51 AM
├─ /imprint (138ms) nitro 9:43:51 AM
├─ / (142ms) nitro 9:43:51 AM
├─ /privacy-policy (141ms) nitro 9:43:51 AM
├─ /imprint/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (19ms) (skipped) nitro 9:43:51 AM
├─ /posts (142ms) nitro 9:43:51 AM
├─ /_payload.json?219037ad-9996-4bfb-b388-75710e43084f (16ms) (skipped) nitro 9:43:51 AM
├─ /privacy-policy/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (15ms) (skipped) nitro 9:43:51 AM
├─ /posts/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (9ms) (skipped) nitro 9:43:51 AM
├─ /imprint/_payload.json (5ms) nitro 9:43:51 AM
├─ /_payload.json (15ms) nitro 9:43:51 AM
├─ /privacy-policy/_payload.json (10ms) nitro 9:43:51 AM
├─ /posts/_payload.json (4ms) nitro 9:43:51 AM
├─ /en/privacy-policy (96ms) nitro 9:43:51 AM
├─ /en (100ms) nitro 9:43:51 AM
├─ /es (103ms) nitro 9:43:51 AM
├─ /en/imprint (107ms) nitro 9:43:51 AM
├─ /es/privacy-policy (88ms) nitro 9:43:51 AM
├─ /en/privacy-policy/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (6ms) (skipped) nitro 9:43:51 AM
├─ /es/imprint (113ms) nitro 9:43:51 AM
├─ /en/posts (107ms) nitro 9:43:51 AM
├─ /en/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (8ms) (skipped) nitro 9:43:51 AM
├─ /es/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (6ms) (skipped) nitro 9:43:51 AM
├─ /en/imprint/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (5ms) (skipped) nitro 9:43:51 AM
├─ /es/privacy-policy/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (4ms) (skipped) nitro 9:43:51 AM
├─ /es/imprint/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (11ms) (skipped) nitro 9:43:51 AM
├─ /en/posts/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (9ms) (skipped) nitro 9:43:51 AM
├─ /es/posts (120ms) nitro 9:43:51 AM
├─ /sitemap.xml (4ms) nitro 9:43:51 AM
├─ /de-DE-sitemap.xml (5ms) nitro 9:43:51 AM
├─ /en-US-sitemap.xml (5ms) nitro 9:43:51 AM
├─ /en/privacy-policy/_payload.json (5ms) nitro 9:43:51 AM
├─ /es-ES-sitemap.xml (5ms) nitro 9:43:51 AM
├─ /index-sitemap.xml (5ms) nitro 9:43:51 AM
├─ /es/posts/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (7ms) (skipped) nitro 9:43:51 AM
├─ /es/_payload.json (5ms) nitro 9:43:51 AM
├─ /en/_payload.json (7ms) nitro 9:43:51 AM
├─ /en/imprint/_payload.json (5ms) nitro 9:43:51 AM
├─ /es/privacy-policy/_payload.json (3ms) nitro 9:43:51 AM
├─ /posts/schoen-dass-du-hier-bist (115ms) nitro 9:43:51 AM
├─ /en/posts/_payload.json (2ms) nitro 9:43:51 AM
├─ /es/imprint/_payload.json (10ms) nitro 9:43:51 AM
├─ /es/posts/_payload.json (3ms) nitro 9:43:51 AM
├─ /posts/schoen-dass-du-hier-bist/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (11ms) (skipped) nitro 9:43:51 AM
├─ /en/posts/nice-to-meet-you (24ms) nitro 9:43:51 AM
├─ /en/posts/nice-to-meet-you/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (17ms) (skipped) nitro 9:43:51 AM
├─ /es/posts/bienvenido (12ms) nitro 9:43:51 AM
├─ /es/posts/bienvenido/_payload.json?219037ad-9996-4bfb-b388-75710e43084f (11ms) (skipped) nitro 9:43:51 AM
├─ /posts/schoen-dass-du-hier-bist/_payload.json (3ms) nitro 9:43:51 AM
├─ /en/posts/schoen-dass-du-hier-bist (11ms) nitro 9:43:51 AM
├─ /es/posts/schoen-dass-du-hier-bist (10ms) nitro 9:43:51 AM
├─ /en/posts/nice-to-meet-you/_payload.json (4ms) nitro 9:43:51 AM
├─ /es/posts/nice-to-meet-you (16ms) nitro 9:43:51 AM
├─ /posts/nice-to-meet-you (17ms) nitro 9:43:51 AM
├─ /en/posts/bienvenido (10ms) nitro 9:43:51 AM
├─ /posts/bienvenido (8ms) nitro 9:43:51 AM
├─ /es/posts/bienvenido/_payload.json (3ms) nitro 9:43:51 AM
[9:43:52 AM] WARN Export "useNitroApp" of module "node_modules/nitropack/dist/runtime/app.mjs" was reexported through module "node_modules/nitropack/dist/runtime/index.mjs" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
Either change the import in "node_modules/@nuxtjs/sitemap/dist/runtime/nitro/routes/sitemap_index.xml.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.
├─ /sitemap_index.xml (3ms) nitro 9:43:52 AM
├─ /__sitemap__/en-US.xml (6ms) nitro 9:43:53 AM
├─ /__sitemap__/de-DE.xml (5ms) nitro 9:43:53 AM
├─ /__sitemap__/es-ES.xml (6ms) nitro 9:43:53 AM
ℹ Prerendered 49 routes in 2.819 seconds nitro 9:43:53 AM
✔ Generated public .output/public nitro 9:43:53 AM
✔ You can preview this build using npx serve .output/public nitro 9:43:53 AM
✔ You can now deploy .output/public to any static hosting! 9:43:53 AM
```</div>
The text was updated successfully, but these errors were encountered:
Discussed in #3184
Originally posted by WaldemarEnns October 19, 2024
Description
Hello there! My setup is quite easy:
ℹ See details and code below.
I use SSG for generating my
/posts
route, which contains aNuxtLink
/NuxtLinkLocale
to redirect to the/posts/[slug].vue
page, where theslug
is a value that I fetch usinguseAsyncData
fom my CMS. The slug is a translated string.My issue: Whenever I execute
npm run generate
, my/posts
page is being crawled by the nitro crawler (due toSSG
-> see https://nuxt.com/docs/getting-started/prerendering#crawl-based-pre-rendering) and then the output is basically all possible combinations of /{locale}/posts/{slug} instead of only using the correct slugs for the correct current locale.Example: Expected output
Example: Actual output
As you will notice: I am adding custom prerender routes to my
nuxt.config.ts
in a prerender hook to allow my dynamic and translated blog-post pages to be prerendered as well.What I noticed
I noticed that due to how nuxt-i18n works, the nitro-crawler crawls the
/posts
page and notices theNuxtLink
component. It then renders the/posts
page for each availablelocale
but does not effectively wait foruseAsyncData
to retrieve the correct posts slug to use it for each individual locale - so I end up with all slugs being passed around to all locales, resulting in all possible combinations being prerendered (see output below).Commenting out that
NuxtLink
results in my/posts
pages being prerendered correctly but of course, my/posts/[slug].vue
pages are not prerendered at all (I am wondering why, since I have added those routes within my nitro prerender hook?).Code examples
nuxt.config.ts
/pages/posts/index.vue
/pages/posts/[slug].vue
Executing
npm run generate
resolves in the following output:The text was updated successfully, but these errors were encountered: