Skip to content

pluggable child apps (multiapp) #30

Description

@pi0

Background

When the project structure grows, sometimes it is not convenient to use a flat directory structure or keep everything in a single repo.

Why?

  • A simple way to split big projects into separate parts with separate business logic
  • We already have srcDir implemented in Nuxt. This feature needs a small refactor effort and does not makes core complicated.

Proposed Solution

One can structure a project like this:

├── shop
|  ├── components
|  |  └── nav.vue
|  ├── layouts
|  |  └── admin.vue
|  ├── middleware
|  |  └── admin.js
|  ├── pages
|  |  └── shop
|  |     └── index.vue
|  └── store
|     └── admin.js
├── nuxt.config.js
├── package.json
├── pages
|  └── index.vue
└── store
   └── public.js

The shop/ dir should basically follow the same standard nuxt directory structure. Builder module combines all children app to the main one. And also creates aliases so components inside admin can be required using:

import Nav from '~shop/components/nav

For registering admin app, it should be registered inside nuxt.config. (Items can be npm packages or local dirs)

export default {
  apps: [
    '~/shop'
  ]
}

Limitations

These are problems with current POC. We can progressively enhance this functionality and workaround these limitations.

  • Currently, store and middleware cannot be supported because srcDir is hardcoded in vue-app templates
  • There is no namespace support. (adding admin/ prefix to store modules and pages) -- children will be registered with the same namespace.
  • Just like the main project, child app files are not lodash templates. We can add a template flag to support and copy the template child apps to the .nuxt

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions