2

Is it possible to build or generate only specific pages from a Nuxt project? In other words, a subset of the project.

In example, let's say I have the following pages directory:

pages/
|
|- index.vue
|- about-us.vue
|- pricing.vue
|- moduleA
    |
    |- index.vue
    |- _id.vue
|- moduleB
    |
    |- index.vue
    |- _id.vue

By doing nuxt generate, all pages would be built and the ones that can be pre-render, will be pre-render. Is there a way of only building, for example, everything but moduleB/?

Right now I'm using the nuxt hook generate:extendRoutes to do a list of only the routes that I want to generate as suggested here: https://github.com/nuxt/nuxt.js/issues/2719#issuecomment-362871101 . However, even though only those routes are generated, if one of the routes has a dependency to a module that is not in the list, it will still load that module.

i.e. If everything but moduleB/ is generated, but pricing.vue has a link to moduleB/index.vue, you can still access it by going /pricing => /moduleB

What I want is a subset of the project, so that moduleB/ is not accessible at all without having to fork the project, delete moduleB/, and then build that forked project. Is that possible?

elielr01
  • 66
  • 2
  • 8

1 Answers1

2

Nuxt generate has an api called exclude that can be used to exclude certain routes from being generated. You can read more from here.

I hope this will solve your problem

s4k1b
  • 2,955
  • 1
  • 7
  • 14