vue.jsvue-cli-3

Sharing assets and components between Vue projects


I have 2 Vue applications and they both need to use some common pages and assets (scss files, icons etc.).

The pages they need to share are full pages with access to vuex store and async calls.

What I think to do is to create a single vue app (with the cli) and put both the apps in it and have a shared folder:

vue-project
   - src
     - app1
     - app2
     - shared

But then I have a problem: How do I build/run each app separately?


Solution

  • UPDATE 2022

    The solution I offer below is valid but it's hard to manage and adding new projects is very involved.

    Today there are many monorepo tools that are better at managing these types of projects:

    1. nx
    2. yarn workspaces

    these are just a couple of options but many more exist

    ORIGINAL POST

    So this is what I ended up doing:

    And that's basically it, I now have 2 separate vue apps running and sharing components, store modules, and pages.