Nuxt.js: Multiple pages and layout directories, for modules and monorepos

Created on 3 Oct 2020  ยท  3Comments  ยท  Source: nuxt/nuxt.js

Is your feature request related to a problem? Please describe.

I'd like to decouple certain parts of my app into their own modules and go for a monorepo approach, while still making use of nuxt's file tree structure for pages and layouts.

For example:

```app/
โ”œโ”€ client/
โ”‚ โ”œโ”€ pages/
โ”‚ โ”œโ”€ layouts/
โ”‚ โ”œโ”€ (other nuxt folders...)
โ”‚ โ””โ”€ nuxt.config.js
โ””โ”€ packages/
โ””โ”€ nuxt-module-admin-dashboard/
โ”œโ”€ pages/
โ”‚ โ””โ”€ dashboard/
โ”‚ โ””โ”€ index.vue // { name: 'dashboard', path: '/dashboard', ... }
โ”œโ”€ module.js
โ”œโ”€ server-middleware.js
โ””โ”€ package.json

### Describe the solution you'd like

Support for multiple `pages`/`layouts`-directories (could be extended to other dirs too, `assets`, `static`, etc). 

Examples:

#### Module
```js
export default function () {
  this.addPages(path.resolve(__dirname, 'pages'))
}

nuxt.config.js

dir: {
  pages: [   // array support
    './pages',
    '../packages/nuxt-module-admin-dashboard/pages',
    '../packages/*/pages'   // glob support?
  ]
}

Related issues: https://github.com/nuxt/nuxt.js/issues/2522, https://github.com/nuxt/nuxt.js/issues/7879 and https://github.com/nuxt-community/modules/issues/148

Thoughts or ideas?

feature-request

Most helpful comment

WIP #8188

All 3 comments

WIP #8188

@duurland you can use create-routes temporarily.

Multi app will be natively supported with nuxt3. Please see https://github.com/nuxt/rfcs/issues/30 for context.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadimsg picture vadimsg  ยท  3Comments

danieloprado picture danieloprado  ยท  3Comments

jaredreich picture jaredreich  ยท  3Comments

o-alexandrov picture o-alexandrov  ยท  3Comments

uptownhr picture uptownhr  ยท  3Comments