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

Double run on generate #27

Closed
scottsweb opened this issue May 1, 2018 — with CMTY · 3 comments

Comments

Copy link

commented May 1, 2018 — with CMTY

Version

0.1.1

Reproduction link

https://github.com/nuxt-community/sitemap-module

Steps to reproduce

Create a new routes section in your nuxt.config.js file with a console.log statement like so:

  sitemap: {
    path: '/sitemap.xml',
    cacheTime: 1000 * 60 * 15,
    generate: true, 
	gzip: true,
	async routes() {
		console.log( '....routes()' )
                ...

What is expected ?

Only one log is output during generate.

What is actually happening?

Multiple log entries are output:

....routes()
  nuxt: Call build:before hooks (3) +0ms
  nuxt:pwa Adding icons +0ms
  nuxt:pwa Adding manifest +0ms
  nuxt:pwa Adding meta +0ms
  nuxt:build Generating files... +4ms
  nuxt:build Generating routes... +8ms
....routes()

Additional comments?

This is an issue because with a dynamically generated set of routes, the API gets hit twice for every request (as far as I can tell).

Using 1.4.0 of nuxt.

This bug report is available on Nuxt.js community (#c25)

@cmty cmty bot added the cmty:bug-report label May 1, 2018

@scottsweb

This comment has been minimized.

Copy link
Author

commented May 3, 2018

Looking at this some more, I think it would be best to trigger the sitemap generation on the generate:done hook as documented here: https://nuxtjs.org/api/internals-generator#hooks

This will allow people to generate routes (via an api) for the generate routes method in nuxt.config.js, cache the results and then pass the cache on to this sitemap module.

@NicoPennec NicoPennec self-assigned this May 3, 2018

@NicoPennec

This comment has been minimized.

Copy link
Member

commented May 3, 2018

Hi Scott, thanks for your report. It's a known issue due to Nuxt <1.x limitation.

I'm working on a refactoring based on the new hooks from Nuxt >=1.x, so It's a breaking change.
It will be release very soon.

@pschaub

This comment has been minimized.

Copy link

commented Jun 19, 2018

@NicoPennec Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.