d3xter-dev / sitemap-module-nuxt-3

Sitemap Module for Nuxt 3
https://sitemap.nuxtjs.org
MIT License
63 stars 12 forks source link

can't follow the output directory name set by nitro #17

Open leosin opened 1 year ago

leosin commented 1 year ago

for some reason, I changed the output directory to be named _output

with this option

nitro: {
    output: {
      dir: '~/_output',
    },
  },

but when i run build, the sitemap.xml still generated in default output dir .output/public

how can fix it ?

Anoesj commented 1 year ago

Same issue as described in #13. If you happen to use pnpm, you can include this patch for now (in new root dir called patches):

diff --git a/dist/module.mjs b/dist/module.mjs
index 42d5b5120a05a0ee4038eaab31cf94c6c4a9a12f..d4a80714319f34b251bec82bfc1d472ca2ee4617 100644
--- a/dist/module.mjs
+++ b/dist/module.mjs
@@ -289,7 +289,7 @@ async function generateSitemaps(options, globalCache, nuxtInstance, depth = 0) {
   if (!nuxtInstance.options.generate?.dir) {
     nuxtInstance.options.generate.dir = nuxtInstance.options.srcDir;
   }
-  const publicDir = "/.output/public";
+  const publicDir = path.relative(nuxtInstance.options.generate.dir, nuxtInstance._nitro.options.output.publicDir);
   const isSitemapIndex = options && options.sitemaps && Array.isArray(options.sitemaps) && options.sitemaps.length > 0;
   if (isSitemapIndex) {
     await generateSitemapIndex(options, globalCache, nuxtInstance, depth, publicDir);

To enable, add to your package.json:

{
  "pnpm": {
    "patchedDependencies": {
      "@funken-studio/sitemap-nuxt-3@4.0.4": "patches/@funken-studio__sitemap-nuxt-3@4.0.4.patch"
    }
  }
}
leosin commented 1 year ago

thank you , A bit complicated for me, but already great solution 😊

ErwinAI commented 1 year ago

Having the same problem, but with Vercel. The NITRO_PRESET is set to either vercel or vercel-edge. This causes the output dir to be .vercel/output/static in my case (ssr: false / static). See screenshot below for my build log.

image