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

@nuxt/sitemap not supported? #20

Closed
midblue opened this issue Aug 20, 2019 · 6 comments
Closed

@nuxt/sitemap not supported? #20

midblue opened this issue Aug 20, 2019 · 6 comments

Comments

@midblue
Copy link

midblue commented Aug 20, 2019

Hi! I'm using nuxt-generate-cluster to generate my static site (nuxt-generate -b).
Latest version of Nuxt, latest everything.
At the end of my generation, under normal circumstances (i.e. nuxt generate), my sitemap gets generated. Great!
However, with nuxt-generate-cluster, this doesn't seem to happen. Is there any way I can manually generate the sitemap, or add a hook the end of this other generate function?

nuxt.config.js:

...
modules: [
    'nuxt-i18n',
    '@nuxtjs/feed',
    '@nuxtjs/sitemap',
  ],
...
  generate: {
    dir: './docs',
    fallback: '404.html',
    workers: 4,
    workerConcurrency: 20,
    concurrency: 20,
    routes: () => {...}
  },
...
This question is available on Nuxt community (#c11)
@ghost ghost closed this as completed Aug 20, 2019
@ghost ghost added the cmty:question label Aug 20, 2019
@pimlie pimlie reopened this Aug 20, 2019
@nuxt-community nuxt-community deleted a comment Aug 20, 2019
@pimlie
Copy link
Member

pimlie commented Aug 20, 2019

@nuxt/sitemap creates the sitemap in the generate:done hook. This is incompatible with nuxt-generate-cluster as the generate:done hook will be called for every batch that a worker completes. Also the route cache will be empty as the cache is filled on the master and the generate:done hook is called on the workers.

Untested, but ncg has a done hook you could maybe use to manually call the generate:done hook on the master. Unfortunately this doesnt receive the nuxt instance, so you need to get that from a nuxt hook: Since v.2.7.0 the Nuxt instance is passed as second arg to the done method:

// nuxt.config.js
...
  generate: {
    done({ duration, errors, workerInfo }, nuxt) {
      nuxt.callHook('generate:done')
    }
  }

Its a bit hacky but it might just work ;)

@midblue
Copy link
Author

midblue commented Aug 21, 2019

I see! Thanks!

@sebbean
Copy link

sebbean commented Sep 18, 2019

@midblue would love to know if you got this working w/ relative ease!

thinking about using it on my app as well (3k+ pages, hitting time limit on netlify deploy)

@midblue
Copy link
Author

midblue commented Sep 21, 2019

I did! I literally did just what pimile said above and it works perfectly.

@pimlie
Copy link
Member

pimlie commented Jan 17, 2020

Since v.2.7.0 the Nuxt instance is passed as second arg to the done method, no need for using a Nuxt hook to get the Nuxt instance anymore

@pimlie pimlie closed this as completed Jan 17, 2020
@simplenotezy
Copy link

@sebbean pro tip: build locally, then use Netlify CLI to push your code; that way you don't need to bypass the build minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants