Get static routes automatically like with the regular nuxt generate command

christophmayrhofer
10
christophmayrhofer
commented 4 months ago

I would like to use nuxt-generate as a replacement for nuxt generate

Unfortunately it generates 0 routes unless I manually define them in the generate.routes option

How can I have it automatically generate all routes based on the files in my pages folders the way that the original nuxt generate command does (it does not require me to define the routes in the nuxt.config.js file)

0
pimlie
593
pimlie
commented 4 months ago

The static routes are added / generated when you build Nuxt by supplying -b to the nuxt-generate command. The first time you run nuxt-generate after changing some code in your nuxt project you always have to (re-)build Nuxt. Once the build is complete, it shouldnt be necessary to (re-)generate the static routes again as they shouldnt have changed.

0
christophmayrhofer
10
christophmayrhofer
commented 4 months ago

@pimlie Thanks for the quick reply. Is it possible to use multiple workers for the static sites (build process) as well?

0
pimlie
593
pimlie
commented 4 months ago

That should already happen by default. The build takes place in the master thread, after the build has completed it takes the static routes from the build process and the dynamic routes from the generate.routes options, combines them and send those to the workers. The next time you run the nuxt-generate command (without the -b option) it will only use the dynamic routes.

0
christophmayrhofer
10
christophmayrhofer
commented 4 months ago

@pimlie Ok, I think it was a misunderstanding on my side. I thought that this package would also allow to speed up the build process by using multiple workers/cores. I was not aware that these are two independent steps. I suppose there is no way to utilize multiple cores for the build.

0
pimlie
593
pimlie
commented 4 months ago

Well actually there are ways to make the Nuxt webpack build use multiple threads. See eg parallel-webpack.

It seems btw that Nuxt 2 will supports this by default, see: https://medium.com/nuxt/nuxt-2-is-coming-oh-yeah-212c1a9e1a67

0
christophmayrhofer
10
christophmayrhofer
commented 4 months ago

@pimlie Thank you for your help. I'll give nuxt 2 a try.

0
Informations
Question โ€ข Unresolved
#c6 - Created 4 months ago