Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd an option to nuxt generate to generate a single route #6138
Comments
|
You could already implement this yourself in generate: {
routes() {
const rIdx = process.argv.indexOf('-r')
if (rIdx) { // it will never be 0 as that would be the node/nuxt command
return [
process.argv[rIdx + 1]
]
}
// return default / all routes
}
} |
|
Nice solution, thanks! But I tried it now and even using the Looking around, it looks like I'd need a way to set the |
|
Hi ! I'm also facing this issue right now while making a blog. I will have a growing number of pages and doing the |
|
Much easier to just manage your dist folder a bit, no need to change anything in nuxt for that: $ yarn generate
$ rsync -auv dist/* production-build/
$ yarn generate --no-build -r /single/route
$ rsync -auv dist/* production-build/and to start over: $ rm production-build/* -Rf |
|
Ok that seems like a good workaround! so you think having this built into nuxt would be useless/out of scope? |
|
I think it'd be a good fit for static generation |
|
About full static mode, re-generating a single route might be difficult for the payload hash @manniL |
|
@Atinux damn, thats right |
|
Yes, you want to look at the target PR :) |
|
Would love this as well. It doesn't work quite well now, as when people edit one page in the CMS whole site has to be regenerated which takes around 2000 seconds. |
|
Having the same trouble with my project, I have a |
|
We are looking to archive the same goal for our full static project when generating dynamic routes. We want to avoid regenerating the whole website for specific changes / addition made in the content. Next.js offer a very interesting incremental static generation : https://reactions-demo.now.sh/ How could we archive the same ? |
|
This could be done with some code in your config. With Nuxt full static the site won't be rebuilt, and you can turn off the crawler and just specify a smaller set of URLs in the generate options. |
Thanks for your reply. Unfortunately, when generating a smaller subset of routes. The other routes are removed from the /dist folder, thus when syncing to my external static storage, they are deleted too. I tried using the Still looking for a way to customize which pages are generated or not depending on payload of dynamic routes. |
|
Just to be sure. The "good way" would be to |
|
@f3ltron without knowing @wlarch exact scenario, I would say yes, but even then, I wouldn't worry about the comparison, just the build/generate part. A use case would be a CMS, where a content editor would "publish" a piece of content, and then trigger a webhook that would generate that specific route. |
|
Got the very same problem: What if you have a site with about 5.000 posts but you change only the content of one of them? Therefore, it would be useful to have an option, just as @hesselberg has described. |
|
@hesselberg This is exactly what we have though. We maintain a CMS that allow the creation and modification of content. Any action on the content would trigger a webhook for generating a specific single page or set of pages. The generate files would then be uploaded to the static hosting. |
|
I've found this approach: https://github.com/hanbyul-here/nuxt-incremental-build-exp In local dev mode it works fine, however if I use it on Netlify, deploying fails. |
|
no matter what I am doing it just generate everything
|
|
As we know static gen cache node_modules. Base on that: https://nuxtjs.org/blog/nuxt-static-improvements#introduction
I am trying things I think I understood what you wanted no? |
What problem does this feature solve?
Example use case:
A static generated app with thousands of routes, like an e-commerce having a route for each product.
Apart from scheduling
nuxt generateto run periodically and generate all static and dynamic routes, it would be nice to have the possibility to generate the static files for a single route, for example in a hook when the related backend item is updated.In a situation where there's a high frequency of updates, re-generating all the dynamic routes every time there's an update to a single one is not really efficient. This way, for every update, just the interested route is re-generated and replaces the previous one (if present).
What does the proposed changes look like?
Update the
nuxt generatecommand to accept a -r or --routes option, for example:nuxt generate --no-build -r /products/42