nuxt / bridge

🌉 Experience Nuxt 3 features on existing Nuxt 2 projects
MIT License
273 stars 29 forks source link

Feature proposal: backport `pages: true` option #687

Open AndreyYolkin opened 1 year ago

AndreyYolkin commented 1 year ago

Environment

-

Reproduction

-

Describe the bug

Nuxt 3 allows us to pass pages: true in nuxt.config.ts to enable vue-router and prevent using default page. This helps in situation when all pages are defined via extendPages. Bridge can have this feature too, because Nuxt 2 has build.createRotes, which tells builder to use vue-router even if pages folder does not exist.

Code, which we need to add to that file:

  if (config.pages && typeof config.build?.createRoutes !== 'function') {
    config.build = config.build || {}
    config.build.createRoutes = () => []
  }

So proposal is:

  1. Add the code above to the "config mormalizer" in module.cjs and also check how it works with disabled nitro.
  2. Update bridge-schema accordingly
  3. Decide, does we need to align behavior with Nuxt 2 or Nuxt 3, if this option turned off and pages folder does not exist. I didn't check that, but I think it differs.

I can help with 1 and 2 items

Additional context

No response

Logs

No response

danielroe commented 1 year ago

Good idea - and thank you. I think it makes sense to align with Nuxt 3 here.