-
Notifications
You must be signed in to change notification settings - Fork 12
Hardcoded .output/public
causing issues on Netlify
#13
base: experimental
Are you sure you want to change the base?
Conversation
…nerate.dir` as `generate.dir` isn't documented by Nuxt and a Nuxt module should probably not change a user's Nuxt config
.output/public
causing issues on Netlify
Thanks! I will have a look |
Hey @d3xter-dev, I edited the original post, because I found out it has to do with the |
Changes look good to me. @d3xter-dev Any chance this can be merged / released? |
Tbh this probably needs some extra work if some tests are failing. It just needs an extra set of eyes for a few hours. |
Any updates? |
As a workaround for now, you can use this guide, replace the query with the dynamic routes. https://content.nuxtjs.org/guide/recipes/sitemap For example: // server/routes/sitemap.xml.ts
import { SitemapStream, streamToPromise } from 'sitemap'
export default defineEventHandler(async (event) => {
const config = useRuntimeConfig()
const links = await $fetch('/api/routes')
const sitemap = new SitemapStream({
hostname: config.public.storyblok.siteUrl,
})
for (const link of links) {
sitemap.write({
url: link,
changefreq: 'monthly'
})
}
sitemap.end()
return streamToPromise(sitemap)
}) Make sure to update your nuxt config to prerender the sitemap for static generation: nitro: {
prerender: {
routes: ['/sitemap.xml'],
}
} |
same issue here with vercel |
Any plans to merge this? |
Hey!
I've run into some issues with this module when deploying a statically generated Nuxt app (using
nuxt generate
) to Netlify.This module seems to assume that the output dir is always
.output/public
in the Nuxt source directory, because sitemaps are always basically written topath.join(nuxtInstance.options.srcDir, '.output/public)
, but Nitro recognizes Netlify (probably by checkingprocess.env.NETLIFY
), setsNITRO_PRESET
tonetlify
and that changes the output directory todist
instead of.output/public
. I tried to fix this in a PR, but I'm still getting some failing tests.Could you look into this? Consider my PR just an experiment, I'm not a very experienced open source dev 😅.
You can mimic Nitro's behavior on Netlify by running
NITRO_PRESET=netlify yarn build-module
. If ran, the current tests fail too.